| 1 | package Google::RestApi::Auth::ServiceAccount; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | our $VERSION = '2.2.5'; | |||||||||
| 4 | |||||||||||
| 5 | 2 | ▶ | use Google::RestApi::Setup; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 2 | ▶ | use WWW::Google::Cloud::Auth::ServiceAccount (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 2 | ▶ | use parent 'Google::RestApi::Auth'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=1.8
Pod
undocumented
| |||||||||||
| 12 | 1 | my $class = shift; | |||||||||
| 13 | |||||||||||
| 14 | 1 | my %p = @_; | |||||||||
| 15 | # config_file must be resolved before merge_config_file can read it. | ||||||||||
| 16 | 1 | resolve_config_file_path(\%p, 'config_file'); | |||||||||
| 17 | 1 | my $self = merge_config_file(%p); | |||||||||
| 18 | # account_file may have come from the YAML; resolve relative names against | ||||||||||
| 19 | # the auth config_file's dir first, then the caller-supplied config_dir. | ||||||||||
| 20 | 1 | resolve_config_file_path($self, 'account_file'); | |||||||||
| 21 | 0 | state $check = signature( | |||||||||
| 22 | bless => !!0, | ||||||||||
| 23 | named => [ | ||||||||||
| 24 | config_dir => ReadableDir, { optional => 1 }, | ||||||||||
| 25 | config_file => ReadableFile, { optional => 1 }, | ||||||||||
| 26 | account_file => ReadableFile, | ||||||||||
| 27 | scope => ArrayRef[Str], | ||||||||||
| 28 | ], | ||||||||||
| 29 | ); | ||||||||||
| 30 | 0 | $self = $check->(%$self); | |||||||||
| 31 | 0 | $self = bless $self, $class; | |||||||||
| 32 | |||||||||||
| 33 | my $auth = WWW::Google::Cloud::Auth::ServiceAccount->new( | ||||||||||
| 34 | credentials_path => $self->{account_file}, | ||||||||||
| 35 | # undocumented feature of WWW::Google::Cloud::Auth::ServiceAccount | ||||||||||
| 36 | 0 | scope => join(' ', @{ $self->{scope} }), | |||||||||
| 37 | ); | ||||||||||
| 38 | 0 | $self->{auth} = $auth; | |||||||||
| 39 | |||||||||||
| 40 | 0 | return $self; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 0 | ▶ | sub headers { | ||||||||
|
Subroutine
headers: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 44 | 0 | my $self = shift; | |||||||||
| 45 | 0 | my $access_token = $self->access_token(); | |||||||||
| 46 | 0 | $self->{headers} = [ Authorization => "Bearer $access_token" ]; | |||||||||
| 47 | 0 | return $self->{headers}; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | sub access_token { | ||||||||
|
Subroutine
access_token: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 51 | 0 | my $self = shift; | |||||||||
| 52 | $self->{access_token} = $self->{auth}->get_token() | ||||||||||
| 53 | 0 | ▶ | or LOGDIE "Service Account Auth failed"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 0 | return $self->{access_token}; | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 2 | 1; | |||||||||
| 58 | |||||||||||
| 59 | __END__ | ||||||||||