Google::RestApi::OAuth2 - OAuth2 support for Google Rest APIs
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);
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.
client id. You can get it at https://code.google.com/apis/console#access.
The client secret paired with the client id.
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
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.
Robin Murray <email@example.com<gt>, copied and modifed from Net::Google::DataAPI::Auth::OAuth2.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.