NAME
Net::Google::DataAPI::Auth::OAuth2 - OAuth2 support for Google Data APIs
SYNOPSIS
use Net::Google::DataAPI::Auth::OAuth2;
my $oauth2 = Net::Google::DataAPI::Auth::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',
# );
# show the user $url and get $code
# if you're making web app, you will do:
#
# return $c->redirect($auth->authorize_url());
#
# getting $code from the request to the 'redirect_uri' in web apps:
#
# my $code = $c->req->param('code');
#
# in installed apps:
#
# use Term::Prompt;
# my $code = prompt('x', 'paste the code: ', '', '');
my $token = $oauth2->get_access_token($code) or die;
# after retrieving $token, you can use $oauth2 with Net::Google::DataAPI items:
my $client = Net::Google::Spreadsheets->new(auth => $oauth2);
DESCRIPTION
Net::Google::DataAPI::Auth::OAuth2 interacts with google OAuth 2.0 service and adds Authorization header to given request.
ATTRIBUTES
You can make Net::Google::DataAPI::Auth::OAuth2 instance with those arguments below:
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.
AUTHOR
Nobuo Danjou <danjou@soffritto.org>
SEE ALSO
https://developers.google.com/accounts/docs/OAuth2
you can see sample implementations for oauth2 client both as installed and web app in the eg directory of this distribution.
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.