OAuth/Provider/Salesforce.pm untested

filter: Statementstmt 0.0% 0 / 17 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 26 CC 2 SCAR 12.0
CC
2
Cov
0%
post_process
6.0
config
2.0
BEGIN
2.0
CRAP 3.3
1 package Dancer2::Plugin::Auth::OAuth::Provider::Salesforce;
2  
3 use strict;
4 use parent 'Dancer2::Plugin::Auth::OAuth::Provider';
5  
6 use HTTP::Request::Common;
7  
8 sub config { {
9 version => 2,
10 urls => {
11 authorize_url => 'https://login.salesforce.com/services/oauth2/authorize',
12 access_token_url => 'https://login.salesforce.com/services/oauth2/token',
13 },
14 query_params => {
15 authorize => {
16 response_type => 'code',
17 scope => 'id',
18 },
19 access => {
20 grant_type => 'authorization_code',
21 }
22 }
23 } }
24  
25 sub post_process {
26 my ($self, $session) = @_;
27  
28 my $session_data = $session->read('oauth');
29  
30 my $resp = $self->{ua}->request(
31 GET $session_data->{salesforce}{id} . '?access_token=' .
32 $session_data->{salesforce}{access_token}
33 );
34  
35 if( $resp->is_success ) {
36 my $user = $self->_stringify_json_booleans(
37 JSON::MaybeXS::decode_json( $resp->decoded_content )
38 );
39 $session_data->{salesforce}{user_info} = $user;
40 $session->write('oauth', $session_data);
41 }
42 }
43  
44 1;