Google-API-Client

 view release on metacpan or  search on metacpan

eg/service_accounts/reseller.pl  view on Meta::CPAN


my $file = "$FindBin::Bin/../client_secrets.json";
my $privateKey = "$FindBin::Bin/../client_secrets.json";

my @scopes = (
    'https://www.googleapis.com/auth/apps.order'
);

my $auth_driver = Google::API::OAuth2::SignedJWT->new({
    service_account_name => '<< service account email here >>', 
    private_key => "$FindBin::<<private key path here >>",
    sub => '<< sub is optional, but can be here... >>',
    scopes => join(" ", @scopes)
});

my $response = $service->customers->get((
    customerId => 'google.com'
))->execute({
    auth_driver => $auth_driver
});

lib/Google/API/OAuth2/SignedJWT.pm  view on Meta::CPAN

    $args->{access_token} = $json_response->{access_token};
    $args->{token_type} = $json_response->{token_type};

    bless { %$args }, $self;
}

sub _get_access_token {
    my ($self, $args) = @_;

    # fetch private key contents.
    my $key_contents = $self->_readfile($args->{private_key});

    my $jwt_params = {
      iss => $args->{service_account_name},
      scope => $args->{scopes},
      aud => OAUTH2_CLAIM_AUDIENCE,
      exp => time() + OAUTH2_TOKEN_LIFETIME_SECS,
      iat => time()
    };

    # sub is defined, push to the array



( run in 0.634 second using v1.01-cache-2.11-cpan-a5abf4f5562 )