| 1 | package WWW::FBX::Role::Auth; | ||||||||||||||||||||||||||||
| 2 | 23 | ▶ | use 5.014001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 23 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 23 | ▶ | use Digest::HMAC_SHA1 qw/ hmac_sha1_hex /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 23 | has [ qw/app_token track_id/ ] => ( isa => 'Str', is => 'rw', default => ''); | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 0 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 9 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 10 | 0 | my $au_sts; | |||||||||||||||||||||||||||
| 11 | my $challenge; | ||||||||||||||||||||||||||||
| 12 | 0 | my $res; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | #Do not perform connection automatically | ||||||||||||||||||||||||||||
| 15 | 0 | ▶ | return if $self->noauth; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | #Get API version if we're called first | ||||||||||||||||||||||||||||
| 18 | 0 | $self->api_version; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | unless ( $self->app_token and $self->track_id ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->app_token and $self->track_id
MC/DC0%0/2
$self->app_token and $self->track_id
$self->app_token
$self->track_id
Truth table0%0/3
A and B
A= $self->app_tokenB= $self->track_id
| |||||||||||||||||||||||||||||
| 21 | #Request token | ||||||||||||||||||||||||||||
| 22 | 0 | $res = $self->req_auth ( { app_id => $self->app_id, | |||||||||||||||||||||||||||
| 23 | app_name => $self->app_name, | ||||||||||||||||||||||||||||
| 24 | app_version => $self->app_version, | ||||||||||||||||||||||||||||
| 25 | device_name => $self->device_name } ); | ||||||||||||||||||||||||||||
| 26 | 0 | $self->track_id( $res->{track_id} ); | |||||||||||||||||||||||||||
| 27 | 0 | $self->app_token( $res->{app_token} ); | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | #Check auth status or wait for physical granting on the device | ||||||||||||||||||||||||||||
| 31 | 0 | $res = $self->auth_progress( $self->track_id ); | |||||||||||||||||||||||||||
| 32 | 0 | ▶ | while( ( $au_sts = $res->{status} ) eq "pending" ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 0 | $challenge = $res->{challenge}; | |||||||||||||||||||||||||||
| 34 | 0 | print "Please Confirm on the FB - Merci d'autoriser sur la FB\n"; | |||||||||||||||||||||||||||
| 35 | 0 | $res = $self->auth_progress( $self->track_id ); | |||||||||||||||||||||||||||
| 36 | 0 | sleep 1; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | die "Authorization not granted($au_sts)" unless $au_sts eq "granted"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | $challenge = $self->login->{challenge} unless ($challenge); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | $res = $self->open_session( { | |||||||||||||||||||||||||||
| 44 | app_id => $self->app_id, | ||||||||||||||||||||||||||||
| 45 | app_version => $self->app_version, | ||||||||||||||||||||||||||||
| 46 | password => hmac_sha1_hex( $challenge, $self->app_token ), | ||||||||||||||||||||||||||||
| 47 | } ); | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | $self->ua->default_header('X-Fbx-App-Auth' => $res->{session_token}); | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 23 | 1; | |||||||||||||||||||||||||||
| 54 | __END__ | ||||||||||||||||||||||||||||