API-Google
view release on metacpan or search on metacpan
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19xx name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the
appropriate parts of the General Public License. Of course, the
commands you use may be called something other than `show w' and `show
c'; they could even be mouse-clicks or menu items--whatever suits your
program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here a sample; alter the names:
"perl" : "5.006"
}
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/pavelsr/API-Google/issues"
},
"repository" : {
"type" : "git",
"url" : "git://github.com/pavelsr/API-Google.git",
"web" : "https://github.com/pavelsr/API-Google"
}
},
"version" : "0.12",
"x_serialization_backend" : "Cpanel::JSON::XS version 3.0225"
}
[AutoPrereqs]
[GatherDir]
; exclude test script from build
exclude_filename = test.pl
exclude_filename = gapi.conf
[PodWeaver]
[ReadmeAnyFromPod]
type = markdown
filename = README.md
location = build
[CopyFilesFromBuild]
copy = README.md
[MetaJSON]
[GitHub::Meta]
[ChangelogFromGit]
lib/API/Google.pm view on Meta::CPAN
$h->{debug} = $params->{debug};
$h->{max_refresh_attempts} = $params->{max_refresh_attempts} || 5;
return bless $h, $class;
}
sub refresh_access_token {
my ($self, $params) = @_;
warn "Attempt to refresh access_token with params: ".Dumper $params if $self->{debug};
$params->{grant_type} = 'refresh_token';
$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->{ua};
lib/API/Google/Server.pm view on Meta::CPAN
my $config = Config::JSON->new($ENV{'GOAUTH_TOKENSFILE'});
delete $ENV{'GOAUTH_TOKENSFILE'};
# authorize_url and token_url can be retrieved from OAuth discovery document
# https://github.com/marcusramberg/Mojolicious-Plugin-OAuth2/issues/52
plugin "OAuth2" => {
google => {
key => $config->get('gapi/client_id'), # $config->{gapi}{client_id},
secret => $config->get('gapi/client_secret'), #$config->{gapi}{client_secret},
authorize_url => 'https://accounts.google.com/o/oauth2/v2/auth?response_type=code',
token_url => 'https://www.googleapis.com/oauth2/v4/token'
}
};
helper get_new_tokens => sub {
my ($c,$auth_code) = @_;
my $hash = {};
$hash->{code} = $c->param('code');
$hash->{redirect_uri} = $c->url_for->to_abs->to_string;
$hash->{client_id} = $config->get('gapi/client_id');
$hash->{client_secret} = $config->get('gapi/client_secret');
$hash->{grant_type} = 'authorization_code';
my $tokens = $c->ua->post('https://www.googleapis.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 https://developers.google.com/identity/protocols/OpenIDConnect#validatinganidtoken for more details
lib/API/Google/Server.pm view on Meta::CPAN
the same terms as the Perl 5 programming language system itself.
=cut
__DATA__
@@ oauth.html.ep
<%= link_to "Click here to get API tokens", $c->oauth2->auth_url("google",
scope => "email profile https://www.googleapis.com/auth/plus.profile.emails.read https://www.googleapis.com/auth/calendar",
authorize_query => { access_type => 'offline'} )
%>
<br><br>
<a href="https://developers.google.com/+/web/api/rest/oauth#authorization-scopes">
Check more about authorization scopes</a>
( run in 1.156 second using v1.01-cache-2.11-cpan-df04353d9ac )