Repository URL to install this package:
|
Version:
2.1.0.jo1 ▾
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module gdata.auth</title>
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="gdata.html"><font color="#ffffff">gdata</font></a>.auth</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/afshar/src/external-gdata-release/google3/src/gdata/auth.py">/usr/local/google/home/afshar/src/external-gdata-release/google3/src/gdata/auth.py</a></font></td></tr></table>
<p><tt># Copyright (C) 2007 - 2009 Google Inc.<br>
#<br>
# Licensed under the Apache License, Version 2.0 (the "License");<br>
# you may not use this file except in compliance with the License.<br>
# You may obtain a copy of the License at<br>
#<br>
# <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a><br>
#<br>
# Unless required by applicable law or agreed to in writing, software<br>
# distributed under the License is distributed on an "AS IS" BASIS,<br>
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br>
# See the License for the specific language governing permissions and<br>
# limitations under the License.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="atom.html">atom</a><br>
<a href="cgi.html">cgi</a><br>
<a href="gdata.html">gdata</a><br>
<a href="math.html">math</a><br>
<a href="gdata.oauth.html">gdata.oauth</a><br>
<a href="gdata.oauth.rsa.html">gdata.oauth.rsa</a><br>
</td><td width="25%" valign=top><a href="random.html">random</a><br>
<a href="re.html">re</a><br>
<a href="time.html">time</a><br>
<a href="types.html">types</a><br>
</td><td width="25%" valign=top><a href="urllib.html">urllib</a><br>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="gdata.auth.html#OAuthInputParams">OAuthInputParams</a>
</font></dt><dt><font face="helvetica, arial"><a href="gdata.auth.html#OAuthSignatureMethod">OAuthSignatureMethod</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="atom.http_interface.html#GenericToken">atom.http_interface.GenericToken</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="gdata.auth.html#ClientLoginToken">ClientLoginToken</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="gdata.auth.html#AuthSubToken">AuthSubToken</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="gdata.auth.html#SecureAuthSubToken">SecureAuthSubToken</a>
</font></dt></dl>
</dd>
</dl>
</dd>
<dt><font face="helvetica, arial"><a href="gdata.auth.html#OAuthToken">OAuthToken</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="AuthSubToken">class <strong>AuthSubToken</strong></a>(<a href="gdata.auth.html#ClientLoginToken">ClientLoginToken</a>)</font></td></tr>
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="gdata.auth.html#AuthSubToken">AuthSubToken</a></dd>
<dd><a href="gdata.auth.html#ClientLoginToken">ClientLoginToken</a></dd>
<dd><a href="atom.http_interface.html#GenericToken">atom.http_interface.GenericToken</a></dd>
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="AuthSubToken-get_token_string"><strong>get_token_string</strong></a>(self)</dt><dd><tt>Removes AUTHSUB_AUTH_LABEL to give just the token value.</tt></dd></dl>
<dl><dt><a name="AuthSubToken-set_token_string"><strong>set_token_string</strong></a>(self, token_string)</dt></dl>
<hr>
Methods inherited from <a href="gdata.auth.html#ClientLoginToken">ClientLoginToken</a>:<br>
<dl><dt><a name="AuthSubToken-__init__"><strong>__init__</strong></a>(self, auth_header<font color="#909090">=None</font>, scopes<font color="#909090">=None</font>)</dt></dl>
<dl><dt><a name="AuthSubToken-__str__"><strong>__str__</strong></a>(self)</dt></dl>
<dl><dt><a name="AuthSubToken-perform_request"><strong>perform_request</strong></a>(self, http_client, operation, url, data<font color="#909090">=None</font>, headers<font color="#909090">=None</font>)</dt><dd><tt>Sets the Authorization header and makes the HTTP request.</tt></dd></dl>
<dl><dt><a name="AuthSubToken-valid_for_scope"><strong>valid_for_scope</strong></a>(self, url)</dt><dd><tt>Tells the caller if the token authorizes access to the desired URL.</tt></dd></dl>
<hr>
Data descriptors inherited from <a href="atom.http_interface.html#GenericToken">atom.http_interface.GenericToken</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="ClientLoginToken">class <strong>ClientLoginToken</strong></a>(<a href="atom.http_interface.html#GenericToken">atom.http_interface.GenericToken</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Stores the Authorization header in auth_header and adds to requests.<br>
<br>
This token will add it's Authorization header to an HTTP request<br>
as it is made. Ths token class is simple but<br>
some Token classes must calculate portions of the Authorization header<br>
based on the request being made, which is why the token is responsible<br>
for making requests via an http_client parameter.<br>
<br>
Args:<br>
auth_header: str The value for the Authorization header.<br>
scopes: list of str or atom.url.Url specifying the beginnings of URLs<br>
for which this token can be used. For example, if scopes contains<br>
'<a href="http://example.com/foo">http://example.com/foo</a>', then this token can be used for a request to<br>
'<a href="http://example.com/foo/bar">http://example.com/foo/bar</a>' but it cannot be used for a request to<br>
'<a href="http://example.com/baz">http://example.com/baz</a>'<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="gdata.auth.html#ClientLoginToken">ClientLoginToken</a></dd>
<dd><a href="atom.http_interface.html#GenericToken">atom.http_interface.GenericToken</a></dd>
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="ClientLoginToken-__init__"><strong>__init__</strong></a>(self, auth_header<font color="#909090">=None</font>, scopes<font color="#909090">=None</font>)</dt></dl>
<dl><dt><a name="ClientLoginToken-__str__"><strong>__str__</strong></a>(self)</dt></dl>
<dl><dt><a name="ClientLoginToken-get_token_string"><strong>get_token_string</strong></a>(self)</dt><dd><tt>Removes PROGRAMMATIC_AUTH_LABEL to give just the token value.</tt></dd></dl>
<dl><dt><a name="ClientLoginToken-perform_request"><strong>perform_request</strong></a>(self, http_client, operation, url, data<font color="#909090">=None</font>, headers<font color="#909090">=None</font>)</dt><dd><tt>Sets the Authorization header and makes the HTTP request.</tt></dd></dl>
<dl><dt><a name="ClientLoginToken-set_token_string"><strong>set_token_string</strong></a>(self, token_string)</dt></dl>
<dl><dt><a name="ClientLoginToken-valid_for_scope"><strong>valid_for_scope</strong></a>(self, url)</dt><dd><tt>Tells the caller if the token authorizes access to the desired URL.</tt></dd></dl>
<hr>
Data descriptors inherited from <a href="atom.http_interface.html#GenericToken">atom.http_interface.GenericToken</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="OAuthInputParams">class <strong>OAuthInputParams</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Stores OAuth input parameters.<br>
<br>
This class is a store for OAuth input parameters viz. consumer key and secret,<br>
signature method and RSA key.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="OAuthInputParams-GetConsumer"><strong>GetConsumer</strong></a>(self)</dt><dd><tt>Gets the OAuth consumer.<br>
<br>
Returns:<br>
<a href="__builtin__.html#object">object</a> of type <oauth.oauth.Consumer></tt></dd></dl>
<dl><dt><a name="OAuthInputParams-GetSignatureMethod"><strong>GetSignatureMethod</strong></a>(self)</dt><dd><tt>Gets the OAuth signature method.<br>
<br>
Returns:<br>
<a href="__builtin__.html#object">object</a> of supertype <oauth.oauth.<a href="#OAuthSignatureMethod">OAuthSignatureMethod</a>></tt></dd></dl>
<dl><dt><a name="OAuthInputParams-__init__"><strong>__init__</strong></a>(self, signature_method, consumer_key, consumer_secret<font color="#909090">=None</font>, rsa_key<font color="#909090">=None</font>, requestor_id<font color="#909090">=None</font>)</dt><dd><tt>Initializes <a href="__builtin__.html#object">object</a> with parameters required for using OAuth mechanism.<br>
<br>
NOTE: Though consumer_secret and rsa_key are optional, either of the two<br>
is required depending on the value of the signature_method.<br>
<br>
Args:<br>
signature_method: class which provides implementation for strategy class<br>
oauth.oauth.<a href="#OAuthSignatureMethod">OAuthSignatureMethod</a>. Signature method to be used for<br>
signing each request. Valid implementations are provided as the<br>
constants defined by gdata.auth.<a href="#OAuthSignatureMethod">OAuthSignatureMethod</a>. Currently<br>
they are gdata.auth.<a href="#OAuthSignatureMethod">OAuthSignatureMethod</a>.RSA_SHA1 and<br>
gdata.auth.<a href="#OAuthSignatureMethod">OAuthSignatureMethod</a>.HMAC_SHA1. Instead of passing in<br>
the strategy class, you may pass in a string for 'RSA_SHA1' or <br>
'HMAC_SHA1'. If you plan to use OAuth on App Engine (or another<br>
WSGI environment) I recommend specifying signature method using a<br>
string (the only options are 'RSA_SHA1' and 'HMAC_SHA1'). In these<br>
environments there are sometimes issues with pickling an <a href="__builtin__.html#object">object</a> in <br>
which a member references a class or function. Storing a string to<br>
refer to the signature method mitigates complications when<br>
pickling.<br>
consumer_key: string Domain identifying third_party web application.<br>
consumer_secret: string (optional) Secret generated during registration.<br>
Required only for HMAC_SHA1 signature method.<br>
rsa_key: string (optional) Private key required for RSA_SHA1 signature<br>
method.<br>
requestor_id: string (optional) User email adress to make requests on<br>
their behalf. This parameter should only be set when performing<br>
2 legged OAuth requests.</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="OAuthSignatureMethod">class <strong>OAuthSignatureMethod</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Holds valid OAuth signature methods.<br>
<br>
RSA_SHA1: Class to build signature according to RSA-SHA1 algorithm.<br>
HMAC_SHA1: Class to build signature according to HMAC-SHA1 algorithm.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>HMAC_SHA1</strong> = <class 'gdata.oauth.OAuthSignatureMethod_HMAC_SHA1'></dl>
<dl><dt><strong>RSA_SHA1</strong> = <class 'gdata.auth.RSA_SHA1'><dd><tt>Provides implementation for abstract methods to return RSA certs.</tt></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="OAuthToken">class <strong>OAuthToken</strong></a>(<a href="atom.http_interface.html#GenericToken">atom.http_interface.GenericToken</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Stores the token key, token secret and scopes for which token is valid.<br>
<br>
This token adds the authorization header to each request made. It<br>
re-calculates authorization header for every request since the OAuth<br>
signature to be added to the authorization header is dependent on the<br>
request parameters.<br>
<br>
Attributes:<br>
key: str The value for the OAuth token i.e. token key.<br>
secret: str The value for the OAuth token secret.<br>
scopes: list of str or atom.url.Url specifying the beginnings of URLs<br>
for which this token can be used. For example, if scopes contains<br>
'<a href="http://example.com/foo">http://example.com/foo</a>', then this token can be used for a request to<br>
'<a href="http://example.com/foo/bar">http://example.com/foo/bar</a>' but it cannot be used for a request to<br>
'<a href="http://example.com/baz">http://example.com/baz</a>'<br>
oauth_input_params: <a href="#OAuthInputParams">OAuthInputParams</a> OAuth input parameters.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="gdata.auth.html#OAuthToken">OAuthToken</a></dd>
<dd><a href="atom.http_interface.html#GenericToken">atom.http_interface.GenericToken</a></dd>
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="OAuthToken-GetAuthHeader"><strong>GetAuthHeader</strong></a>(self, http_method, http_url, realm<font color="#909090">=''</font>)</dt><dd><tt>Get the authentication header.<br>
<br>
Args:<br>
http_method: string HTTP method i.e. operation e.g. GET, POST, PUT, etc.<br>
http_url: string or atom.url.Url HTTP URL to which request is made.<br>
realm: string (default='') realm parameter to be included in the<br>
authorization header.<br>
<br>
Returns:<br>
dict Header to be sent with every subsequent request after<br>
authentication.</tt></dd></dl>
<dl><dt><a name="OAuthToken-__init__"><strong>__init__</strong></a>(self, key<font color="#909090">=None</font>, secret<font color="#909090">=None</font>, scopes<font color="#909090">=None</font>, oauth_input_params<font color="#909090">=None</font>)</dt></dl>
<dl><dt><a name="OAuthToken-__str__"><strong>__str__</strong></a>(self)</dt></dl>
<dl><dt><a name="OAuthToken-get_token_string"><strong>get_token_string</strong></a>(self)</dt><dd><tt>Returns the token string.<br>
<br>
The token string returned is of format<br>
oauth_token=[0]&oauth_token_secret=[1], where [0] and [1] are some strings.<br>
<br>
Returns:<br>
A token string of format oauth_token=[0]&oauth_token_secret=[1],<br>
where [0] and [1] are some strings. If self.<strong>secret</strong> is absent, it just<br>
returns oauth_token=[0]. If self.<strong>key</strong> is absent, it just returns<br>
oauth_token_secret=[1]. If both are absent, it returns None.</tt></dd></dl>
<dl><dt><a name="OAuthToken-perform_request"><strong>perform_request</strong></a>(self, http_client, operation, url, data<font color="#909090">=None</font>, headers<font color="#909090">=None</font>)</dt><dd><tt>Sets the Authorization header and makes the HTTP request.</tt></dd></dl>
<dl><dt><a name="OAuthToken-set_token_string"><strong>set_token_string</strong></a>(self, token_string)</dt><dd><tt>Sets the token key and secret from the token string.<br>
<br>
Args:<br>
token_string: str Token string of form<br>
oauth_token=[0]&oauth_token_secret=[1]. If oauth_token is not present,<br>
self.<strong>key</strong> will be None. If oauth_token_secret is not present,<br>
self.<strong>secret</strong> will be None.</tt></dd></dl>
<dl><dt><a name="OAuthToken-valid_for_scope"><strong>valid_for_scope</strong></a>(self, url)</dt></dl>
<hr>
Data descriptors inherited from <a href="atom.http_interface.html#GenericToken">atom.http_interface.GenericToken</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="SecureAuthSubToken">class <strong>SecureAuthSubToken</strong></a>(<a href="gdata.auth.html#AuthSubToken">AuthSubToken</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Stores the rsa private key, token, and scopes for the secure AuthSub token.<br>
<br>
This token adds the authorization header to each request made. It<br>
re-calculates authorization header for every request since the secure AuthSub<br>
signature to be added to the authorization header is dependent on the<br>
request parameters.<br>
<br>
Attributes:<br>
rsa_key: string The RSA private key in PEM format that the token will<br>
use to sign requests<br>
token_string: string (optional) The value for the AuthSub token.<br>
scopes: list of str or atom.url.Url specifying the beginnings of URLs<br>
for which this token can be used. For example, if scopes contains<br>
'<a href="http://example.com/foo">http://example.com/foo</a>', then this token can be used for a request to<br>
'<a href="http://example.com/foo/bar">http://example.com/foo/bar</a>' but it cannot be used for a request to<br>
'<a href="http://example.com/baz">http://example.com/baz</a>'<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="gdata.auth.html#SecureAuthSubToken">SecureAuthSubToken</a></dd>
<dd><a href="gdata.auth.html#AuthSubToken">AuthSubToken</a></dd>
<dd><a href="gdata.auth.html#ClientLoginToken">ClientLoginToken</a></dd>
<dd><a href="atom.http_interface.html#GenericToken">atom.http_interface.GenericToken</a></dd>
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="SecureAuthSubToken-GetAuthHeader"><strong>GetAuthHeader</strong></a>(self, http_method, http_url)</dt><dd><tt>Generates the Authorization header.<br>
<br>
The form of the secure AuthSub Authorization header is<br>
Authorization: AuthSub token="token" sigalg="sigalg" data="data" sig="sig"<br>
and data represents a string in the form<br>
data = http_method http_url timestamp nonce<br>
<br>
Args:<br>
http_method: string HTTP method i.e. operation e.g. GET, POST, PUT, etc.<br>
http_url: string or atom.url.Url HTTP URL to which request is made.<br>
<br>
Returns:<br>
dict Header to be sent with every subsequent request after authentication.</tt></dd></dl>
<dl><dt><a name="SecureAuthSubToken-__init__"><strong>__init__</strong></a>(self, rsa_key, token_string<font color="#909090">=None</font>, scopes<font color="#909090">=None</font>)</dt></dl>
<dl><dt><a name="SecureAuthSubToken-__str__"><strong>__str__</strong></a>(self)</dt></dl>
<dl><dt><a name="SecureAuthSubToken-get_token_string"><strong>get_token_string</strong></a>(self)</dt></dl>
<dl><dt><a name="SecureAuthSubToken-perform_request"><strong>perform_request</strong></a>(self, http_client, operation, url, data<font color="#909090">=None</font>, headers<font color="#909090">=None</font>)</dt><dd><tt>Sets the Authorization header and makes the HTTP request.</tt></dd></dl>
<dl><dt><a name="SecureAuthSubToken-set_token_string"><strong>set_token_string</strong></a>(self, token_string)</dt></dl>
<hr>
Methods inherited from <a href="gdata.auth.html#ClientLoginToken">ClientLoginToken</a>:<br>
<dl><dt><a name="SecureAuthSubToken-valid_for_scope"><strong>valid_for_scope</strong></a>(self, url)</dt><dd><tt>Tells the caller if the token authorizes access to the desired URL.</tt></dd></dl>
<hr>
Data descriptors inherited from <a href="atom.http_interface.html#GenericToken">atom.http_interface.GenericToken</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-AuthSubTokenFromHttpBody"><strong>AuthSubTokenFromHttpBody</strong></a>(http_body)</dt><dd><tt>Extracts the AuthSub token from an HTTP body string.<br>
<br>
Used to find the new session token after making a request to upgrade a<br>
single use AuthSub token.<br>
<br>
Args:<br>
http_body: str The repsonse from the server which contains the AuthSub<br>
key. For example, this function would find the new session token<br>
from the server's response to an upgrade token request.<br>
<br>
Returns:<br>
The header value to use for Authorization which contains the AuthSub<br>
token.</tt></dd></dl>
<dl><dt><a name="-AuthSubTokenFromUrl"><strong>AuthSubTokenFromUrl</strong></a>(url)</dt><dd><tt>Extracts the AuthSub token from the URL. <br>
<br>
Used after the AuthSub redirect has sent the user to the 'next' page and<br>
appended the token to the URL. This function returns the value to be used<br>
in the Authorization header. <br>
<br>
Args:<br>
url: str The URL of the current page which contains the AuthSub token as<br>
a URL parameter.</tt></dd></dl>
<dl><dt><a name="-GenerateAuthSubUrl"><strong>GenerateAuthSubUrl</strong></a>(next, scope, secure<font color="#909090">=False</font>, session<font color="#909090">=True</font>, request_url<font color="#909090">='https://www.google.com/accounts/AuthSubRequest'</font>, domain<font color="#909090">='default'</font>)</dt><dd><tt>Generate a URL at which the user will login and be redirected back.<br>
<br>
Users enter their credentials on a Google login page and a token is sent<br>
to the URL specified in next. See documentation for AuthSub login at:<br>
<a href="http://code.google.com/apis/accounts/AuthForWebApps.html">http://code.google.com/apis/accounts/AuthForWebApps.html</a><br>
<br>
Args:<br>
request_url: str The beginning of the request URL. This is normally<br>
'<a href="http://www.google.com/accounts/AuthSubRequest">http://www.google.com/accounts/AuthSubRequest</a>' or <br>
'/accounts/AuthSubRequest'<br>
next: string The URL user will be sent to after logging in.<br>
scope: string The URL of the service to be accessed.<br>
secure: boolean (optional) Determines whether or not the issued token<br>
is a secure token.<br>
session: boolean (optional) Determines whether or not the issued token<br>
can be upgraded to a session token.<br>
domain: str (optional) The Google Apps domain for this account. If this<br>
is not a Google Apps account, use 'default' which is the default<br>
value.</tt></dd></dl>
<dl><dt><a name="-GenerateClientLoginAuthToken"><strong>GenerateClientLoginAuthToken</strong></a>(http_body)</dt><dd><tt>Returns the token value to use in Authorization headers.<br>
<br>
Reads the token from the server's response to a Client Login request and<br>
creates header value to use in requests.<br>
<br>
Args:<br>
http_body: str The body of the server's HTTP response to a Client Login<br>
request<br>
<br>
Returns:<br>
The value half of an Authorization header.</tt></dd></dl>
<dl><dt><a name="-GenerateClientLoginRequestBody"><strong>GenerateClientLoginRequestBody</strong></a> = generate_client_login_request_body(email, password, service, source, account_type<font color="#909090">='HOSTED_OR_GOOGLE'</font>, captcha_token<font color="#909090">=None</font>, captcha_response<font color="#909090">=None</font>)</dt><dd><tt>Creates the body of the autentication request<br>
<br>
See <a href="http://code.google.com/apis/accounts/AuthForInstalledApps.html#Request">http://code.google.com/apis/accounts/AuthForInstalledApps.html#Request</a><br>
for more details.<br>
<br>
Args:<br>
email: str<br>
password: str<br>
service: str<br>
source: str<br>
account_type: str (optional) Defaul is 'HOSTED_OR_GOOGLE', other valid<br>
values are 'GOOGLE' and 'HOSTED'<br>
captcha_token: str (optional)<br>
captcha_response: str (optional)<br>
<br>
Returns:<br>
The HTTP body to send in a request for a client login token.</tt></dd></dl>
<dl><dt><a name="-GenerateOAuthAccessTokenUrl"><strong>GenerateOAuthAccessTokenUrl</strong></a>(authorized_request_token, oauth_input_params, access_token_url<font color="#909090">='https://www.google.com/accounts/OAuthGetAccessToken'</font>, oauth_version<font color="#909090">='1.0'</font>, oauth_verifier<font color="#909090">=None</font>)</dt><dd><tt>Generates URL at which user will login to authorize the request token.<br>
<br>
Args:<br>
authorized_request_token: gdata.auth.<a href="#OAuthToken">OAuthToken</a> OAuth authorized request<br>
token.<br>
oauth_input_params: <a href="#OAuthInputParams">OAuthInputParams</a> OAuth input parameters. <br>
access_token_url: string The beginning of the authorization URL. This is<br>
normally 'https://www.google.com/accounts/OAuthGetAccessToken' or<br>
'/accounts/OAuthGetAccessToken'<br>
oauth_version: str (default='1.0') oauth_version parameter.<br>
oauth_verifier: str (optional) If present, it is assumed that the client<br>
will use the OAuth v1.0a protocol which includes passing the<br>
oauth_verifier (as returned by the SP) in the access token step.<br>
<br>
Returns:<br>
atom.url.Url OAuth access token URL.</tt></dd></dl>
<dl><dt><a name="-GenerateOAuthAuthorizationUrl"><strong>GenerateOAuthAuthorizationUrl</strong></a>(request_token, authorization_url<font color="#909090">='https://www.google.com/accounts/OAuthAuthorizeToken'</font>, callback_url<font color="#909090">=None</font>, extra_params<font color="#909090">=None</font>, include_scopes_in_callback<font color="#909090">=False</font>, scopes_param_prefix<font color="#909090">='oauth_token_scope'</font>)</dt><dd><tt>Generates URL at which user will login to authorize the request token.<br>
<br>
Args:<br>
request_token: gdata.auth.<a href="#OAuthToken">OAuthToken</a> OAuth request token.<br>
authorization_url: string The beginning of the authorization URL. This is<br>
normally 'https://www.google.com/accounts/OAuthAuthorizeToken' or<br>
'/accounts/OAuthAuthorizeToken'<br>
callback_url: string (optional) The URL user will be sent to after<br>
logging in and granting access.<br>
extra_params: dict (optional) Additional parameters to be sent.<br>
include_scopes_in_callback: Boolean (default=False) if set to True, and<br>
if 'callback_url' is present, the 'callback_url' will be modified to<br>
include the scope(s) from the request token as a URL parameter. The<br>
key for the 'callback' URL's scope parameter will be<br>
OAUTH_SCOPE_URL_PARAM_NAME. The benefit of including the scope URL as<br>
a parameter to the 'callback' URL, is that the page which receives<br>
the OAuth token will be able to tell which URLs the token grants<br>
access to.<br>
scopes_param_prefix: string (default='oauth_token_scope') The URL<br>
parameter key which maps to the list of valid scopes for the token.<br>
This URL parameter will be included in the callback URL along with<br>
the scopes of the token as value if include_scopes_in_callback=True.<br>
<br>
Returns:<br>
atom.url.Url OAuth authorization URL.</tt></dd></dl>
<dl><dt><a name="-GenerateOAuthRequestTokenUrl"><strong>GenerateOAuthRequestTokenUrl</strong></a>(oauth_input_params, scopes, request_token_url<font color="#909090">='https://www.google.com/accounts/OAuthGetRequestToken'</font>, extra_parameters<font color="#909090">=None</font>)</dt><dd><tt>Generate a URL at which a request for OAuth request token is to be sent.<br>
<br>
Args:<br>
oauth_input_params: <a href="#OAuthInputParams">OAuthInputParams</a> OAuth input parameters.<br>
scopes: list of strings The URLs of the services to be accessed.<br>
request_token_url: string The beginning of the request token URL. This is<br>
normally 'https://www.google.com/accounts/OAuthGetRequestToken' or<br>
'/accounts/OAuthGetRequestToken'<br>
extra_parameters: dict (optional) key-value pairs as any additional<br>
parameters to be included in the URL and signature while making a<br>
request for fetching an OAuth request token. All the OAuth parameters<br>
are added by default. But if provided through this argument, any<br>
default parameters will be overwritten. For e.g. a default parameter<br>
oauth_version 1.0 can be overwritten if<br>
extra_parameters = {'oauth_version': '2.0'}<br>
<br>
Returns:<br>
atom.url.Url OAuth request token URL.</tt></dd></dl>
<dl><dt><a name="-GetCaptchaChallenge"><strong>GetCaptchaChallenge</strong></a> = get_captcha_challenge(http_body, captcha_base_url<font color="#909090">='http://www.google.com/accounts/'</font>)</dt><dd><tt>Returns the URL and token for a CAPTCHA challenge issued by the server.<br>
<br>
Args:<br>
http_body: str The body of the HTTP response from the server which <br>
contains the CAPTCHA challenge.<br>
captcha_base_url: str This function returns a full URL for viewing the <br>
challenge image which is built from the server's response. This<br>
base_url is used as the beginning of the URL because the server<br>
only provides the end of the URL. For example the server provides<br>
'Captcha?ctoken=Hi...N' and the URL for the image is<br>
'<a href="http://www.google.com/accounts/Captcha?ctoken=Hi...N">http://www.google.com/accounts/Captcha?ctoken=Hi...N</a>'<br>
<br>
Returns:<br>
A dictionary containing the information needed to repond to the CAPTCHA<br>
challenge, the image URL and the ID token of the challenge. The <br>
dictionary is in the form:<br>
{'token': string identifying the CAPTCHA image,<br>
'url': string containing the URL of the image}<br>
Returns None if there was no CAPTCHA challenge in the response.</tt></dd></dl>
<dl><dt><a name="-OAuthTokenFromHttpBody"><strong>OAuthTokenFromHttpBody</strong></a>(http_body)</dt><dd><tt>Parses the HTTP response body and returns an OAuth token.<br>
<br>
The returned OAuth token will just have key and secret parameters set.<br>
It won't have any knowledge about the scopes or oauth_input_params. It is<br>
your responsibility to make it aware of the remaining parameters.<br>
<br>
Returns:<br>
<a href="#OAuthToken">OAuthToken</a> OAuth token.</tt></dd></dl>
<dl><dt><a name="-OAuthTokenFromUrl"><strong>OAuthTokenFromUrl</strong></a>(url, scopes_param_prefix<font color="#909090">='oauth_token_scope'</font>)</dt><dd><tt>Creates an <a href="#OAuthToken">OAuthToken</a> and sets token key and scopes (if present) from URL.<br>
<br>
After the Google Accounts OAuth pages redirect the user's broswer back to <br>
the web application (using the 'callback' URL from the request) the web app<br>
can extract the token from the current page's URL. The token is same as the<br>
request token, but it is either authorized (if user grants access) or<br>
unauthorized (if user denies access). The token is provided as a <br>
URL parameter named 'oauth_token' and if it was chosen to use<br>
GenerateOAuthAuthorizationUrl with include_scopes_in_param=True, the token's<br>
valid scopes are included in a URL parameter whose name is specified in<br>
scopes_param_prefix.<br>
<br>
Args:<br>
url: atom.url.Url or str representing the current URL. The token value<br>
and valid scopes should be included as URL parameters.<br>
scopes_param_prefix: str (optional) The URL parameter key which maps to<br>
the list of valid scopes for the token.<br>
<br>
Returns:<br>
An <a href="#OAuthToken">OAuthToken</a> with the token key from the URL and set to be valid for<br>
the scopes passed in on the URL. If no scopes were included in the URL,<br>
the <a href="#OAuthToken">OAuthToken</a> defaults to being valid for no scopes. If there was no<br>
'oauth_token' parameter in the URL, this function returns None.</tt></dd></dl>
<dl><dt><a name="-TokenFromHttpBody"><strong>TokenFromHttpBody</strong></a> = token_from_http_body(http_body)</dt><dd><tt>Extracts the AuthSub token from an HTTP body string.<br>
<br>
Used to find the new session token after making a request to upgrade a <br>
single use AuthSub token.<br>
<br>
Args:<br>
http_body: str The repsonse from the server which contains the AuthSub <br>
key. For example, this function would find the new session token<br>
from the server's response to an upgrade token request.<br>
<br>
Returns:<br>
The raw token value to use in an <a href="#AuthSubToken">AuthSubToken</a> <a href="__builtin__.html#object">object</a>.</tt></dd></dl>
<dl><dt><a name="-TokenFromUrl"><strong>TokenFromUrl</strong></a>(url)</dt><dd><tt>Extracts the AuthSub token from the URL.<br>
<br>
Returns the raw token value.<br>
<br>
Args:<br>
url: str The URL or the query portion of the URL string (after the ?) of<br>
the current page which contains the AuthSub token as a URL parameter.</tt></dd></dl>
<dl><dt><a name="-extract_auth_sub_token_from_url"><strong>extract_auth_sub_token_from_url</strong></a>(url, scopes_param_prefix<font color="#909090">='auth_sub_scopes'</font>, rsa_key<font color="#909090">=None</font>)</dt><dd><tt>Creates an <a href="#AuthSubToken">AuthSubToken</a> and sets the token value and scopes from the URL.<br>
<br>
After the Google Accounts AuthSub pages redirect the user's broswer back to <br>
the web application (using the 'next' URL from the request) the web app must<br>
extract the token from the current page's URL. The token is provided as a <br>
URL parameter named 'token' and if generate_auth_sub_url was used to create<br>
the request, the token's valid scopes are included in a URL parameter whose<br>
name is specified in scopes_param_prefix.<br>
<br>
Args:<br>
url: atom.url.Url or str representing the current URL. The token value<br>
and valid scopes should be included as URL parameters.<br>
scopes_param_prefix: str (optional) The URL parameter key which maps to<br>
the list of valid scopes for the token.<br>
<br>
Returns:<br>
An <a href="#AuthSubToken">AuthSubToken</a> with the token value from the URL and set to be valid for<br>
the scopes passed in on the URL. If no scopes were included in the URL,<br>
the <a href="#AuthSubToken">AuthSubToken</a> defaults to being valid for no scopes. If there was no<br>
'token' parameter in the URL, this function returns None.</tt></dd></dl>
<dl><dt><a name="-extract_client_login_token"><strong>extract_client_login_token</strong></a>(http_body, scopes)</dt><dd><tt>Parses the server's response and returns a <a href="#ClientLoginToken">ClientLoginToken</a>.<br>
<br>
Args:<br>
http_body: str The body of the server's HTTP response to a Client Login<br>
request. It is assumed that the login request was successful.<br>
scopes: list containing atom.url.Urls or strs. The scopes list contains<br>
all of the partial URLs under which the client login token is<br>
valid. For example, if scopes contains ['<a href="http://example.com/foo">http://example.com/foo</a>']<br>
then the client login token would be valid for <br>
<a href="http://example.com/foo/bar/baz">http://example.com/foo/bar/baz</a><br>
<br>
Returns:<br>
A <a href="#ClientLoginToken">ClientLoginToken</a> which is valid for the specified scopes.</tt></dd></dl>
<dl><dt><a name="-generate_auth_sub_url"><strong>generate_auth_sub_url</strong></a>(next, scopes, secure<font color="#909090">=False</font>, session<font color="#909090">=True</font>, request_url<font color="#909090">='https://www.google.com/accounts/AuthSubRequest'</font>, domain<font color="#909090">='default'</font>, scopes_param_prefix<font color="#909090">='auth_sub_scopes'</font>)</dt><dd><tt>Constructs a URL string for requesting a multiscope AuthSub token.<br>
<br>
The generated token will contain a URL parameter to pass along the <br>
requested scopes to the next URL. When the Google Accounts page <br>
redirects the broswser to the 'next' URL, it appends the single use<br>
AuthSub token value to the URL as a URL parameter with the key 'token'.<br>
However, the information about which scopes were requested is not<br>
included by Google Accounts. This method adds the scopes to the next<br>
URL before making the request so that the redirect will be sent to <br>
a page, and both the token value and the list of scopes can be <br>
extracted from the request URL. <br>
<br>
Args:<br>
next: atom.url.URL or string The URL user will be sent to after<br>
authorizing this web application to access their data.<br>
scopes: list containint strings The URLs of the services to be accessed.<br>
secure: boolean (optional) Determines whether or not the issued token<br>
is a secure token.<br>
session: boolean (optional) Determines whether or not the issued token<br>
can be upgraded to a session token.<br>
request_url: atom.url.Url or str The beginning of the request URL. This<br>
is normally '<a href="http://www.google.com/accounts/AuthSubRequest">http://www.google.com/accounts/AuthSubRequest</a>' or <br>
'/accounts/AuthSubRequest'<br>
domain: The domain which the account is part of. This is used for Google<br>
Apps accounts, the default value is 'default' which means that the<br>
requested account is a Google Account (@gmail.com for example)<br>
scopes_param_prefix: str (optional) The requested scopes are added as a <br>
URL parameter to the next URL so that the page at the 'next' URL can<br>
extract the token value and the valid scopes from the URL. The key<br>
for the URL parameter defaults to 'auth_sub_scopes'<br>
<br>
Returns:<br>
An atom.url.Url which the user's browser should be directed to in order<br>
to authorize this application to access their information.</tt></dd></dl>
<dl><dt><a name="-generate_client_login_request_body"><strong>generate_client_login_request_body</strong></a>(email, password, service, source, account_type<font color="#909090">='HOSTED_OR_GOOGLE'</font>, captcha_token<font color="#909090">=None</font>, captcha_response<font color="#909090">=None</font>)</dt><dd><tt>Creates the body of the autentication request<br>
<br>
See <a href="http://code.google.com/apis/accounts/AuthForInstalledApps.html#Request">http://code.google.com/apis/accounts/AuthForInstalledApps.html#Request</a><br>
for more details.<br>
<br>
Args:<br>
email: str<br>
password: str<br>
service: str<br>
source: str<br>
account_type: str (optional) Defaul is 'HOSTED_OR_GOOGLE', other valid<br>
values are 'GOOGLE' and 'HOSTED'<br>
captcha_token: str (optional)<br>
captcha_response: str (optional)<br>
<br>
Returns:<br>
The HTTP body to send in a request for a client login token.</tt></dd></dl>
<dl><dt><a name="-get_captcha_challenge"><strong>get_captcha_challenge</strong></a>(http_body, captcha_base_url<font color="#909090">='http://www.google.com/accounts/'</font>)</dt><dd><tt>Returns the URL and token for a CAPTCHA challenge issued by the server.<br>
<br>
Args:<br>
http_body: str The body of the HTTP response from the server which <br>
contains the CAPTCHA challenge.<br>
captcha_base_url: str This function returns a full URL for viewing the <br>
challenge image which is built from the server's response. This<br>
base_url is used as the beginning of the URL because the server<br>
only provides the end of the URL. For example the server provides<br>
'Captcha?ctoken=Hi...N' and the URL for the image is<br>
'<a href="http://www.google.com/accounts/Captcha?ctoken=Hi...N">http://www.google.com/accounts/Captcha?ctoken=Hi...N</a>'<br>
<br>
Returns:<br>
A dictionary containing the information needed to repond to the CAPTCHA<br>
challenge, the image URL and the ID token of the challenge. The <br>
dictionary is in the form:<br>
{'token': string identifying the CAPTCHA image,<br>
'url': string containing the URL of the image}<br>
Returns None if there was no CAPTCHA challenge in the response.</tt></dd></dl>
<dl><dt><a name="-get_client_login_token"><strong>get_client_login_token</strong></a>(http_body)</dt><dd><tt>Returns the token value for a <a href="#ClientLoginToken">ClientLoginToken</a>.<br>
<br>
Reads the token from the server's response to a Client Login request and<br>
creates the token value string to use in requests.<br>
<br>
Args:<br>
http_body: str The body of the server's HTTP response to a Client Login<br>
request<br>
<br>
Returns:<br>
The token value string for a <a href="#ClientLoginToken">ClientLoginToken</a>.</tt></dd></dl>
<dl><dt><a name="-token_from_http_body"><strong>token_from_http_body</strong></a>(http_body)</dt><dd><tt>Extracts the AuthSub token from an HTTP body string.<br>
<br>
Used to find the new session token after making a request to upgrade a <br>
single use AuthSub token.<br>
<br>
Args:<br>
http_body: str The repsonse from the server which contains the AuthSub <br>
key. For example, this function would find the new session token<br>
from the server's response to an upgrade token request.<br>
<br>
Returns:<br>
The raw token value to use in an <a href="#AuthSubToken">AuthSubToken</a> <a href="__builtin__.html#object">object</a>.</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>AUTHSUB_AUTH_LABEL</strong> = 'AuthSub token='<br>
<strong>PROGRAMMATIC_AUTH_LABEL</strong> = 'GoogleLogin auth='<br>
<strong>__author__</strong> = 'api.jscudder (Jeff Scudder)'</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#7799ee">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
<tr><td bgcolor="#7799ee"><tt> </tt></td><td> </td>
<td width="100%">api.jscudder (Jeff Scudder)</td></tr></table>
</body></html>