JSON;
use Data::Dumper;
sub new {
my ($class, $params) = @_;
my $h = {};
if ($params->{tokensfile}) {
$h->{tokensfile} = Config::JSON->new($params->{tokensfile});
} else {
die 'no json
oken';
$self->{ua}->post('https://www.googleapis.com/oauth2/v4/token' => form => $params)->res->json; # tokens
};
sub client_id {
shift->{tokensfile}->get('gapi/client_id');
}
sub ua {
shift->
->{payload}) {
$tx = $self->{ua}->build_tx(uc $http_method => $params->{route} => $headers => json => $params->{payload})
} else {
die 'wrong http_method on no payload if using POST';
}
YNOPSIS
use API::Google::GCal;
my $gapi = API::Google::GCal->new({ tokensfile => 'config.json' });
my $user = 'someuser@gmail.com';
my $calendar_id = 'ooqfhagr1a91u1510ffdf7vfp
mper;
use Config::JSON;
use Tie::File;
use Crypt::JWT qw(decode_jwt);
use feature 'say';
use Mojo::Util 'getopt';
use Mojolicious::Plugin::OAuth2;
# use Mojo::JWT;
# sub return_json_filename {
# u
les = readdir $dir;
# my @j = grep { $_ =~ /\w+.json/ } @files;
# return $j[0];
# }
# my $f = return_json_filename();
my $config = Config::JSON->new($ENV{'GOAUTH_TOKENSFILE'});
delete $ENV{'GOA
com/oauth2/v4/token' => form => $hash)->res->json;
return $tokens;
};
# =method get_all_google_jwk_keys
# Get all Google JWK keys for validation of JSON Web Token
# Check https://jwt.io/ and http