Net::Google::WebmasterTools::OAuth2 - OAuth2 for Google Webmaster Tools API
version 0.03
use Net::Google::WebmasterTools; use Net::Google::WebmasterTools::OAuth2; my $client_id = "123456789012.apps.googleusercontent.com"; my $client_secret = "rAnDoMsEcReTrAnDoMsEcReT"; my $refresh_token = "RaNdOmSeCrEtRaNdOmSeCrEt"; my $analytics = Net::Google::WebmasterTools->new; # Authenticate my $oauth = Net::Google::WebmasterTools::OAuth2->new( client_id => $client_id, client_secret => $client_secret, ); my $token = $oauth->refresh_access_token($refresh_token); $analytics->token($token);
OAuth2 class for Net::Google::WebmasterTools web service.
Net::Google::WebmasterTools::OAuth2 - OAuth2 for Google WebmasterTools API
my $oauth = Net::Google::WebmasterTools::OAuth2->new( client_id => $client_id, # required client_secret => $client_secret, # required redirect_uri => $redirect_uri, );
Create a new object. Use the client id and client secret from the Google APIs Console. $redirect_uri is optional and defaults to 'urn:ietf:wg:oauth:2.0:oob' for installed applications.
my $url = $oauth->authorize_url;
Returns a Google URL where the user can authenticate, authorize the application and retrieve an authorization code.
my $token = $oauth->get_access_token($code);
Retrieves an access token and a refresh token using an authorization code. Returns a hashref with the following entries:
my $token = $oauth->refresh_access_token($refresh_token);
Retrieves a new access token using a refresh token. Returns a hashref with the following entries:
$oauth->interactive;
Obtain and print an access and refresh token interactively using the console. The user is prompted to visit a Google URL and enter a code from that page.
Nick Wellnhofer <wellnhofer@aevum.de>
This software is copyright (c) 2012 by Nick Wellnhofer.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Rob Hammond <contact@rjh.am>, Nick Wellnhofer <wellnhofer@aevum.de>
This software is copyright (c) 2015 by Nick Wellnhofer.
To install Net::Google::WebmasterTools, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Google::WebmasterTools
CPAN shell
perl -MCPAN -e shell install Net::Google::WebmasterTools
For more information on module installation, please visit the detailed CPAN module installation guide.