| 1 | package Dancer2::Plugin::Auth::OAuth::Provider::Facebook; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use parent 'Dancer2::Plugin::Auth::OAuth::Provider'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use HTTP::Request::Common; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 3 | ▶ | sub config { { | ||||||||
|
Subroutine
config: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 9 | 3 | version => 2, | |||||||||
| 10 | urls => { | ||||||||||
| 11 | authorize_url => 'https://www.facebook.com/dialog/oauth', | ||||||||||
| 12 | access_token_url => 'https://graph.facebook.com/oauth/access_token', | ||||||||||
| 13 | user_info => 'https://graph.facebook.com/me', | ||||||||||
| 14 | }, | ||||||||||
| 15 | query_params => { | ||||||||||
| 16 | authorize => { | ||||||||||
| 17 | response_type => 'code', | ||||||||||
| 18 | scope => 'email,public_profile', | ||||||||||
| 19 | } | ||||||||||
| 20 | } | ||||||||||
| 21 | } } | ||||||||||
| 22 | |||||||||||
| 23 | 1 | ▶ | sub post_process { | ||||||||
|
Subroutine
post_process: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||
| 24 | 1 | my ($self, $session) = @_; | |||||||||
| 25 | |||||||||||
| 26 | 1 | my $fields = ''; | |||||||||
| 27 | 1 | ▶ | if ( exists $self->provider_settings->{fields} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 0 | $fields = "&fields=".$self->provider_settings->{fields}; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 1 | my $session_data = $session->read('oauth'); | |||||||||
| 32 | |||||||||||
| 33 | my $resp = $self->{ua}->request( | ||||||||||
| 34 | GET $self->provider_settings->{urls}{user_info}."?access_token=". | ||||||||||
| 35 | $session_data->{facebook}{access_token}. | ||||||||||
| 36 | 1 | $fields | |||||||||
| 37 | ); | ||||||||||
| 38 | |||||||||||
| 39 | 1 | ▶ | if( $resp->is_success ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 1 | my $user = $self->_stringify_json_booleans( | |||||||||
| 41 | JSON::MaybeXS::decode_json( $resp->content ) | ||||||||||
| 42 | ); | ||||||||||
| 43 | 1 | $session_data->{facebook}{user_info} = $user; | |||||||||
| 44 | 1 | $session->write('oauth', $session_data); | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | 1 | 1; | |||||||||