The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Google::RestApi::OAuth2 - OAuth2 support for Google Rest APIs

SYNOPSIS

use Google::RestApi::OAuth2;

my $oauth2 = Google::RestApi::OAuth2->new(
  client_id      => 'xxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com',
  client_secret  => 'mys3cr33333333333333t',
  scope          => ['http://spreadsheets.google.com/feeds/'],

  # with web apps, redirect_uri is needed:
  # redirect_uri => 'http://your_app.sample.com/callback',
);
my $url = $oauth2->authorize_url();

# you can add optional parameters:
my $url = $oauth2->authorize_url(
  access_type     => 'offline',
  approval_prompt => 'force',
);

# generate an access token from the code returned from Google:
my $token = $oauth2->access_token($code);

DESCRIPTION

Google::RestApi::OAuth2 interacts with google OAuth 2.0 service and adds the 'Authorization' header to subsequent requests.

This was copied from Net::Google::DataAPI::Auth::OAuth2 and modified to fit this framework. The other framework was dated and produced constant warnings to upgrade to Moo. I removed Moose since I didn't use Moose anywhere else in this framework.

ATTRIBUTES

sub new

See https://developers.google.com/accounts/docs/OAuth2 for details.

AUTHOR

Robin Murray <mvsjes@cpan.ork<gt>, copied and modifed from Net::Google::DataAPI::Auth::OAuth2.

SEE ALSO

OAuth2

Google::DataAPI::Auth::OAuth2

https://developers.google.com/accounts/docs/OAuth2

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.