use WebService::GoogleAPI::Client::Discovery;
use WebService::GoogleAPI::Client::AuthStorage::GapiJSON;
use WebService::GoogleAPI::Client::AuthStorage::ServiceAccount;
use Carp;
use CHI;
use Mojo::Uti
assuming it's always
# returning the res. Perhaps mix in something that delegates the
# json method to the res?
# ABSTRACT: Google API Discovery and SDK
# FROM MCE POD -- <p><img src="ht
= $params->{auth_storage};
} elsif ($file = $params->{gapi_json}) {
$storage = WebService::GoogleAPI::Client::AuthStorage::GapiJSON->new(path => $file);
} elsif ($file = $params->{service_acc
trigger => 1;
sub _trigger_path {
my ($self) = @_;
$self->jwt(Mojo::JWT::Google->new(from_json => $self->path));
}
has jwt => is => 'rw';
has tokens => is => 'ro',
default => sub { {
accounts, please see
L<WebService::GoogleAPI::AuthStorage::GapiJSON>.
This backend is only for explicitly passing a service account JSON file. It will
not attempt to find one by itself, or to do the
{
$ret = $self->ua->get($key)->res;
}
if ($ret->is_success) {
my $all = $ret->json;
$self->stats->{network}{get}++;
$self->chi->set($key, $all, '30d');
return $al
he($url, $force, $authenticate)
Retrieves the given API URL, retrieving and caching the returned
JSON. If it gets a 403 Unauthenticated error, then it will try
again using the credentials that are sa
scoveryRestUrl' => 'https://developers.google.com/my-business/samples/mybusiness_google_rest_v4p2.json',
'name' => 'mybusiness'
});
This can also be used to overwrite the cached structure.
gent';
#extends 'Mojo::UserAgent::Mockable';
use WebService::GoogleAPI::Client::AuthStorage::GapiJSON;
use Mojo::UserAgent;
use Data::Dump qw/pp/; # for dev debug
use Data::Printer filters => 'Web
e' => (
is => 'rw',
default => sub {
WebService::GoogleAPI::Client::AuthStorage::GapiJSON->new;
},
handles => [qw/get_access_token scopes user/],
trigger => 1,
isa => sub {
d_tx( $http_method => $path => $headers ) : $self->build_tx( $http_method => $path => $headers => json => $optional_data );
if ($optional_data eq '') {
return $self->build_tx($http_method =>
rage::ConfigJSON;
$WebService::GoogleAPI::Client::AuthStorage::ConfigJSON::VERSION = '0.21';
# ABSTRACT: Specific methods to fetch tokens from JSON data sources
use Moo;
use Config::JSON;
use Carp;
has 'pathToTokensFile' => ( is => 'rw', default => 'gapi.json' ); # default is gapi.json
# has 'tokensfile'; # Config::JSON object pointer
my $tokensfile;
has 'debug' => ( is => 'rw', default =>
kenfile?, global $tokensfile? .. *sigh*
sub setup
{
my ( $self ) = @_;
$tokensfile = Config::JSON->new( $self->pathToTokensFile );
return $self;
}
sub get_credentials_for_refresh
{
my ( $sel
ce::GoogleAPI::Client::AuthStorage::GapiJSON;
our $VERSION = '0.27'; # VERSION
# ABSTRACT: Auth Storage Backend based on gapi.json
use Moo;
use Config::JSON;
use Carp;
with 'WebService::GoogleAP
has 'path' => (is => 'rw', default => './gapi.json'); # default is gapi.json
has 'tokensfile' => (is => 'rw'); # Config::JSON object pointer
# NOTE- this type of class ha
okensfile(Config::JSON->new($self->path));
my $missing = grep !$_, map $self->get_from_storage($_), qw/client_id client_secret/;
croak <<NOCLIENT if $missing;
Malformed gapi.json detected. We need
h tokens from JSON data sources
use Mojo::Base 'WebService::GoogleAPI::Client::AuthStorage';
use Config::JSON;
use Carp;
#has 'pathToTokensFile' => ( is => 'rw', default => 'gapi.json' ); # defa
ult is gapi.json
# has 'tokensfile'; # Config::JSON object pointer
#my $tokensfile;
has 'debug' => ( is => 'rw', default => 0 );
has 'scopes' => ( is => 'rw', default => [] );
has 'client_secret' =
NAME
WebService::GoogleAPI::Client::AuthStorage::Memory - Specific methods to fetch tokens from JSON data sources
=head1 VERSION
version 0.21
=head1 AUTHOR
Peter Scott <localshop@cpan.org>
=hea
x->res->json('/access_token');
unless ($new_token) {
croak "Failed to refresh access token: ", join ' - ', map $tx->res->json("/$_"), qw/error error_description/
if $tx->res->json;
#
$tx->res->json('/access_token');
unless ($new_token) {
croak "Failed to get access token: ", join ' - ', map $tx->res->json("/$_"), qw/error error_description/
if $tx->res->json;
# i
e backends.
This dist comes with two consumers, L<WebService::GoogleAPI::Client::AuthStorage::GapiJSON>
and L<WebService::GoogleAPI::Client::AuthStorage::ServiceAccount>. See those for more info
on ho