| 1 | package Moo::Google::Credentials; | ||||||||||
| 2 | 1 | $Moo::Google::Credentials::VERSION = '0.03'; | |||||||||
| 3 | |||||||||||
| 4 | # ABSTRACT: Credentials for particular Client instance. You can use this module as singleton also if you need to share credentials between two or more modules | ||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | with 'MooX::Singleton'; | |||||||||
| 8 | |||||||||||
| 9 | 1 | has 'access_token' => ( is => 'rw' ); | |||||||||
| 10 | 1 | has 'user' => ( is => 'rw', trigger => \&get_access_token_for_user ) | |||||||||
| 11 | ; # full gmail, like pavel.p.serikov@gmail.com | ||||||||||
| 12 | has 'auth_storage' => | ||||||||||
| 13 | 0 | ▶ | ( is => 'rw', default => sub { Moo::Google::AuthStorage->new } ) | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 14 | 1 | ; # dont delete to able to configure | |||||||||
| 15 | |||||||||||
| 16 | |||||||||||
| 17 | 0 | ▶ | sub get_access_token_for_user { | ||||||||
|
Subroutine
get_access_token_for_user: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 18 | 0 | my $self = shift; | |||||||||
| 19 | 0 | ▶ | if ( $self->auth_storage->is_set ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | { # chech that auth_storage initialized fine | ||||||||||
| 21 | 0 | $self->access_token( | |||||||||
| 22 | $self->auth_storage->get_access_token_from_storage( $self->user ) ); | ||||||||||
| 23 | } | ||||||||||
| 24 | else { | ||||||||||
| 25 | 0 | die "Can get access token for specified user because storage isnt set"; | |||||||||
| 26 | } | ||||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 1 | 1; | |||||||||
| 30 | |||||||||||
| 31 | __END__ | ||||||||||