1Net::Google::AuthSub(3)User Contributed Perl DocumentatioNnet::Google::AuthSub(3)
2
3
4

NAME

6       Net::Google::AuthSub - interact with sites that implement Google style
7       AuthSub
8

SYNOPSIS

10           my $auth = Net::Google::AuthSub->new;
11           my $response = $auth->login($user, $pass);
12
13           if ($response->is_success) {
14               print "Hurrah! Logged in\n";
15           } else {
16               die "Login failed: ".$response->error."\n";
17           }
18
19           my %params = $auth->auth_params;
20           $params{Content_Type}             = 'application/atom+xml; charset=UTF-8';
21           $params{Content}                  = $xml;
22           $params{'X-HTTP-Method-Override'} = 'DELETE';
23
24           my $request = POST $url, %params;
25           my $r = $user_agent->request( $request );
26

ABOUT AUTHSUB

28       AuthSub is Google's method of authentication for their web services. It
29       is also used by other web sites.
30
31       You can read more about it here.
32
33           http://code.google.com/apis/accounts/Authentication.html
34
35       A Google Group for AuthSub is here.
36
37           http://groups.google.com/group/Google-Accounts-API
38

DEALING WITH CAPTCHAS

40       If a login response fails then it may set the error code to
41       'CaptchRequired' and the response object will allow you to retrieve the
42       "captchatoken" and "captchaurl" fields.
43
44       The "captchaurl" will be the url to a captcha image or you can show the
45       user the web page
46
47           https://www.google.com/accounts/DisplayUnlockCaptcha
48
49       Then retry the login attempt passing in the parameters "logintoken"
50       (which is the value of "captchatoken") and "logincaptcha" which is the
51       user's answer to the CAPTCHA.
52
53           my $auth = Net::Google::AuthSub->new;
54           my $res  = $auth->login($user, $pass);
55
56           if (!$res->is_success && $res->error eq 'CaptchaRequired') {
57               my $answer = display_captcha($res->captchaurl);
58               $auth->login($user, $pass, logintoken => $res->captchatoken, logincaptcha => $answer);
59           }
60
61       You can read more here
62
63           http://code.google.com/apis/accounts/AuthForInstalledApps.html#Using
64

METHODS

66   new [param[s]]
67       Return a new authorisation object. The options are
68
69       url The base url of the web service to authenticate against.
70
71           Defaults to "https://google.com/account"
72
73       service
74           Name of the Google service for which authorization is requested
75           such as 'cl' for Calendar.
76
77           Defaults to 'xapi' for calendar.
78
79       source
80           Short string identifying your application, for logging purposes.
81
82           Defaults to 'Net::Google::AuthSub-<VERSION>'
83
84       accountType
85           Type of account to be authenticated.
86
87           Defaults to 'HOSTED_OR_GOOGLE'.
88
89       See
90       http://code.google.com/apis/accounts/AuthForInstalledApps.html#ClientLogin
91       for more details.
92
93   login <username> <password> [opt[s]]
94       Login to google using your username and password.
95
96       Can optionally take a hash of options which will override the default
97       login params.
98
99       Returns a "Net::Google::AuthSub::Response" object.
100
101   authorised
102       Whether or not we're authorised.
103
104   authorized
105       An alias for authorized.
106
107   auth <username> <token>
108       Use the AuthSub method for access.
109
110       See http://code.google.com/apis/accounts/AuthForWebApps.html for
111       details.
112
113   auth_token [token]
114       Get or set the current auth token
115
116   auth_type [type]
117       Get or set the current auth type
118
119       Returns either $Net::Google::AuthSub::CLIENT_LOGIN or
120       $Net::Google::AuthSub::AUTH_SUB.
121
122   request_token <next> <scope> [option[s]]
123       Return a URI object representing the URL which the user should be
124       directed to in order to aquire a single use token.
125
126       The parameters are
127
128       next (required)
129           URL the user should be redirected to after a successful login.
130           This value should be a page on the web application site, and can
131           include query parameters.
132
133       scope (required)
134           URL identifying the service to be accessed. The resulting token
135           will enable access to the specified service only. Some services may
136           limit scope further, such as read-only access.
137
138           For example
139
140               http://www.google.com/calendar/feed
141
142       secure
143           Boolean flag indicating whether the authentication transaction
144           should issue a secure token (1) or a non-secure token (0).  Secure
145           tokens are available to registered applications only.
146
147       session
148           Boolean flag indicating whether the one-time-use token may be
149           exchanged for a session token (1) or not (0).
150
151   session_token
152       Exchange the temporary token for a long-lived session token.
153
154       The single-use token is acquired by visiting the url generated by
155       calling request_token.
156
157       Returns the token if success and undef if failure.
158
159   revoke_token
160       Revoke a valid session token. Session tokens have no expiration date
161       and will remain valid unless revoked.
162
163       Returns 1 if success and undef if failure.
164
165   token_info
166       Call AuthSubTokenInfo to test whether a given session token is valid.
167       This method validates the token in the same way that a Google service
168       would; application developers can use this method to verify that their
169       application is getting valid tokens and handling them appropriately
170       without involving a call to the Google service. It can also be used to
171       get information about the token, including next URL, scope, and secure
172       status, as specified in the original token request.
173
174       Returns a "Net::Google::AuthSub::Response" object on success or undef
175       on failure.
176
177   auth_params
178       Return any parameters needed in an HTTP request to authorise your app.
179

AUTHOR

181       Simon Wistow <simon@thegestalt.org>
182
184       Copyright, 2007 - Simon Wistow
185
186       Released under the same terms as Perl itself
187
188
189
190perl v5.36.0                      2023-01-20           Net::Google::AuthSub(3)
Impressum