| 1 | package Moo::Google::AuthStorage::ConfigJSON; | ||||||||||
| 2 | 1 | $Moo::Google::AuthStorage::ConfigJSON::VERSION = '0.03'; | |||||||||
| 3 | |||||||||||
| 4 | # ABSTRACT: Specific methods to fetch tokens from JSON data sources | ||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Config::JSON; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | has 'pathToTokensFile' => ( is => 'rw', default => 'config.json' ) | |||||||||
| 10 | ; # default is config.json | ||||||||||
| 11 | |||||||||||
| 12 | # has 'tokensfile'; # Config::JSON object pointer | ||||||||||
| 13 | 1 | my $tokensfile; | |||||||||
| 14 | 1 | has 'debug' => ( is => 'rw', default => 0 ); | |||||||||
| 15 | |||||||||||
| 16 | 0 | ▶ | sub setup { | ||||||||
|
Subroutine
setup: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 17 | 0 | my $self = shift; | |||||||||
| 18 | 0 | $tokensfile = Config::JSON->new( $self->pathToTokensFile ); | |||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | 0 | ▶ | sub get_credentials_for_refresh { | ||||||||
|
Subroutine
get_credentials_for_refresh: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 22 | 0 | my ( $self, $user ) = @_; | |||||||||
| 23 | return { | ||||||||||
| 24 | 0 | client_id => $self->get_client_id_from_storage(), | |||||||||
| 25 | client_secret => $self->get_client_secret_from_storage(), | ||||||||||
| 26 | refresh_token => $self->get_refresh_token_from_storage($user) | ||||||||||
| 27 | }; | ||||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 0 | ▶ | sub get_client_id_from_storage { | ||||||||
|
Subroutine
get_client_id_from_storage: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 31 | 0 | $tokensfile->get('gapi/client_id'); | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 0 | ▶ | sub get_client_secret_from_storage { | ||||||||
|
Subroutine
get_client_secret_from_storage: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 35 | 0 | $tokensfile->get('gapi/client_secret'); | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | sub get_refresh_token_from_storage { | ||||||||
|
Subroutine
get_refresh_token_from_storage: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 39 | 0 | my ( $self, $user ) = @_; | |||||||||
| 40 | 0 | ▶ | warn "get_refresh_token_from_storage(" . $user . ")" if $self->debug; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 0 | return $tokensfile->get( 'gapi/tokens/' . $user . '/refresh_token' ); | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 0 | ▶ | sub get_access_token_from_storage { | ||||||||
|
Subroutine
get_access_token_from_storage: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 45 | 0 | my ( $self, $user ) = @_; | |||||||||
| 46 | 0 | $tokensfile->get( 'gapi/tokens/' . $user . '/access_token' ); | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | 0 | ▶ | sub set_access_token_to_storage { | ||||||||
|
Subroutine
set_access_token_to_storage: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 50 | 0 | my ( $self, $user, $token ) = @_; | |||||||||
| 51 | 0 | $tokensfile->set( 'gapi/tokens/' . $user . '/access_token', $token ); | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 1 | 1; | |||||||||
| 55 | |||||||||||
| 56 | __END__ | ||||||||||