NAME

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

SYNOPSIS

use Google::RestApi::Auth::OAuth2Client;

my $oauth2 = Google::RestApi::Auth::OAuth2Client->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::Auth::OAuth2Client interacts with google OAuth 2.0 service and creates the 'Authorization' header for use in Furl or LWP::UserAgent.

To generate a config file and token file for use by this moudle, see: bin/google_restapi_oauth_token_creator in this pacakage.

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 from Moose to Moo. I removed Moose since I didn't use Moose anywhere else in this framework.

ATTRIBUTES

sub new

    config_file: Optional YAML configuration file that can specify any
      or all of the following args:
    client_id: The OAuth2 client id supplied by Google.
    client_secret: The OAuth2 client secret supplied by Google.
    token_file: The file path to the previously saved token (see OAUTH2
      SETUP below). If a config_file is passed, the dirname of the config
      file is tried to resolve the token_file (same directory) if the
      directory portion is omitted.

    You can specify any of the arguments in the optional YAML config file. Any passed in arguments will override what is in the config file.

    * client_id

    client id. You can get it at https://code.google.com/apis/console#access.

    * client_secret

    The client secret paired with the client id.

    * scope

    URL identifying the service(s) to be accessed. You can see the list of the urls to use at: http://code.google.com/intl/en-US/apis/gdata/faq.html#AuthScopes

    * redirect_url

    OAuth2 redirect url. 'urn:ietf:wg:oauth:2.0:oob' will be used if you don't specify it.

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

OAUTH2 SETUP

This class depends on first creating an OAuth2 token session file that you point to via the 'token_file' config param passed via 'new'. See bin/google_restapi_oauth_token_creator and follow the instructions to save your token file.

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.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 198:

You can't have =items (as at line 212) unless the first thing after the =over is an =item