gdata.client
index
/usr/local/svn/gdata-python-client/src/gdata/client.py

Provides a client to interact with Google Data API servers.
 
This module is used for version 2 of the Google Data APIs and is currently
experimental. This module may change in backwards incompatible ways before
the release of version 2.0.0. The primary class in this module is GDClient.
 
  GDClient: handles auth and CRUD operations when communicating with servers.
  GDataClient: deprecated client for version one services. Will be removed.
  create_converter: uses a prototype object to create a converter function.

 
Modules
       
atom
gdata
re
urllib
urlparse

 
Classes
       
atom.client.AtomPubClient(__builtin__.object)
GDClient
exceptions.Exception(exceptions.BaseException)
Error
ClientLoginFailed
ClientLoginTokenMissing
UnableToUpgradeToken
Unauthorized
gdata.service.CaptchaRequired(gdata.service.Error)
CaptchaChallenge
gdata.service.Error(exceptions.Exception)
AuthorizationRequired
gdata.service.GDataService(atom.service.AtomService)
GDataClient
gdata.service.RequestError(gdata.service.Error)
RedirectError

 
class AuthorizationRequired(gdata.service.Error)
    
Method resolution order:
AuthorizationRequired
gdata.service.Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from gdata.service.Error:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class CaptchaChallenge(gdata.service.CaptchaRequired)
    
Method resolution order:
CaptchaChallenge
gdata.service.CaptchaRequired
gdata.service.Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data and other attributes defined here:
captcha_token = None
captcha_url = None

Data descriptors inherited from gdata.service.Error:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class ClientLoginFailed(Error)
    
Method resolution order:
ClientLoginFailed
Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from Error:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class ClientLoginTokenMissing(Error)
    
Method resolution order:
ClientLoginTokenMissing
Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from Error:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class Error(exceptions.Exception)
    
Method resolution order:
Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class GDClient(atom.client.AtomPubClient)
    Communicates with Google Data servers to perform CRUD operations.
 
This class is currently experimental and may change in backwards
incompatible ways.
 
This class exists to simplify the following three areas involved in using
the Google Data APIs.
 
CRUD Operations:
 
The client provides a generic 'request' method for making HTTP requests.
There are a number of convenience methods which are built on top of
request, which include get_feed, get_entry, get_next, post, update, and
delete. These methods contact the Google Data servers.
 
Auth:
 
Reading user-specific private data requires authorization from the user as
do any changes to user data. An auth_token object can be passed into any
of the HTTP requests to set the Authorization header in the request.
 
You may also want to set the auth_token member to a an object which can
use modify_request to set the Authorization header in the HTTP request.
 
If you are authenticating using the email address and password, you can
use the client_login method to obtain an auth token and set the
auth_token member.
 
If you are using browser redirects, specifically AuthSub, you will want
to use gdata.gauth.AuthSubToken.from_url to obtain the token after the
redirect, and you will probably want to updgrade this since use token
to a multiple use (session) token using the upgrade_token method.
 
API Versions:
 
This client is multi-version capable and can be used with Google Data API
version 1 and version 2. The version should be specified by setting the
api_version member to a string, either '1' or '2'.
 
 
Method resolution order:
GDClient
atom.client.AtomPubClient
__builtin__.object

Methods defined here:
ClientLogin = client_login(self, email, password, service, source, account_type='HOSTED_OR_GOOGLE', auth_url='https://www.google.com/accounts/ClientLogin', captcha_token=None, captcha_response=None)
Delete = delete(self, entry, auth_token=None, force=False, **kwargs)
GetEntry = get_entry(self, url, auth_token=None, converter=<function v2_entry_from_response at 0xac5c80>, **kwargs)
GetFeed = get_feed(self, uri, auth_token=None, converter=<function v2_feed_from_response at 0xac77d0>, **kwargs)
GetNext = get_next(self, feed, auth_token=None, converter=None, **kwargs)
ModifyRequest = modify_request(self, http_request)
Post = post(self, entry, uri, auth_token=None, converter=None, **kwargs)
Request = request(self, method=None, uri=None, auth_token=None, http_request=None, converter=None, redirects_remaining=4, **kwargs)
RequestClientLoginToken = request_client_login_token(self, email, password, service, source, account_type='HOSTED_OR_GOOGLE', auth_url=<atom.http_core.Uri object at 0xc117d0>, captcha_token=None, captcha_response=None)
Update = update(self, entry, auth_token=None, force=False, **kwargs)
UpgradeToken = upgrade_token(self, token=None, url=<atom.http_core.Uri object at 0xc11810>)
client_login(self, email, password, service, source, account_type='HOSTED_OR_GOOGLE', auth_url='https://www.google.com/accounts/ClientLogin', captcha_token=None, captcha_response=None)
delete(self, entry, auth_token=None, force=False, **kwargs)
get_entry(self, url, auth_token=None, converter=<function v2_entry_from_response at 0xac5c80>, **kwargs)
get_feed(self, uri, auth_token=None, converter=<function v2_feed_from_response at 0xac77d0>, **kwargs)
get_next(self, feed, auth_token=None, converter=None, **kwargs)
Fetches the next set of results from the feed. 
 
When requesting a feed, the number of entries returned is capped at a
service specific default limit (often 25 entries). You can specify your
own entry-count cap using the max-results URL query parameter. If there
are more results than could fit under max-results, the feed will contain
a next link. This method performs a GET against this next results URL.
 
Returns:
  A new feed object containing the next set of entries in this feed.
modify_request(self, http_request)
Adds or changes request before making the HTTP request.
 
This client will add the API version if it is specified. 
Subclasses may override this method to add their own request 
modifications before the request is made.
post(self, entry, uri, auth_token=None, converter=None, **kwargs)
request(self, method=None, uri=None, auth_token=None, http_request=None, converter=None, redirects_remaining=4, **kwargs)
Make an HTTP request to the server.
 
See also documentation for atom.client.AtomPubClient.request.
 
If a 302 redirect is sent from the server to the client, this client
assumes that the redirect is in the form used by the Google Calendar API.
The same request URI and method will be used as in the original request,
but a gsessionid URL parameter will be added to the request URI with
the value provided in the server's 302 redirect response. If the 302
redirect is not in the format specified by the Google Calendar API, a
RedirectError will be raised containing the body of the server's
response.
 
The method calls the client's modify_request method to make any changes
required by the client before the request is made. For example, a
version 2 client could add a GData-Version: 2 header to the request in
its modify_request method.
 
Args:
  method: str
  uri: atom.http_core.Uri, str, or unicode
  auth_token:
  http_request: (optional) atom.http_core.HttpRequest
  converter: function which takes the body of the response as it's only
             argument and returns the desired object.
  redirects_remaining: (optional) int, if this number is 0 and the
                       server sends a 302 redirect, the request method
                       will raise an exception. This parameter is used in
                       recursive request calls to avoid an infinite loop.
 
Any additional arguments are passed through to 
atom.client.AtomPubClient.request.
 
Returns:
  An HTTP response object (see atom.http_core.HttpResponse for a
  description of the object's interface) if no converter was
  specified. If a converter function was provided, the results of
  calling the converter are returned.
request_client_login_token(self, email, password, service, source, account_type='HOSTED_OR_GOOGLE', auth_url=<atom.http_core.Uri object at 0xc117d0>, captcha_token=None, captcha_response=None)
update(self, entry, auth_token=None, force=False, **kwargs)
Edits the entry on the server by sending the XML for this entry.
 
Performs a PUT and converts the response to a new entry object with a
matching class to the entry passed in.
 
Args:
  entry:
  auth_token:
  force: boolean stating whether an update should be forced. Defaults to
         False. Normally, if a change has been made since the passed in
         entry was obtained, the server will not overwrite the entry since
         the changes were based on an obsolete version of the entry.
         Setting force to True will cause the update to silently
         overwrite whatever version is present.
 
Returns:
  A new Entry object of a matching type to the entry which was passed in.
upgrade_token(self, token=None, url=<atom.http_core.Uri object at 0xc11810>)
Asks the Google auth server for a multi-use AuthSub token.
 
For details on AuthSub, see:
http://code.google.com/apis/accounts/docs/AuthSub.html
 
Args:
  token: gdata.gauth.AuthSubToken (optional) If no token is passed in, 
         the client's auth_token member is used to request the new token.
         The token object will be modified to contain the new session 
         token string.
  url: str or atom.http_core.Uri (optional) The URL to which the token
       upgrade request should be sent. Defaults to: 
       https://www.google.com/accounts/AuthSubSessionToken
 
Returns:
  The upgraded gdata.gauth.AuthSubToken object.

Data and other attributes defined here:
api_version = None

Methods inherited from atom.client.AtomPubClient:
Get = get(self, uri=None, auth_token=None, http_request=None, **kwargs)
Put = put(self, uri=None, data=None, auth_token=None, http_request=None, **kwargs)
__init__(self, http_client=None, host=None, auth_token=None, **kwargs)
Creates a new AtomPubClient instance.
 
Args:
  http_client: An object capable of performing HTTP requests through a
               request method. This object is used to perform the request
               when the AtomPubClient's request method is called. Used to
               allow HTTP requests to be directed to a mock server, or use
               an alternate library instead of the default of httplib to
               make HTTP requests.
  host: str The default host name to use if a host is not specified in the
        requested URI.
  auth_token: An object which sets the HTTP Authorization header when its
              modify_request method is called.
get(self, uri=None, auth_token=None, http_request=None, **kwargs)
put(self, uri=None, data=None, auth_token=None, http_request=None, **kwargs)

Data descriptors inherited from atom.client.AtomPubClient:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from atom.client.AtomPubClient:
auth_token = None
host = None

 
class GDataClient(gdata.service.GDataService)
    This class is deprecated. 
 
All functionality has been migrated to gdata.service.GDataService.
 
 
Method resolution order:
GDataClient
gdata.service.GDataService
atom.service.AtomService
__builtin__.object

Methods defined here:
ClientLogin(self, username, password, service_name, source=None, account_type=None, auth_url=None, login_token=None, login_captcha=None)
Delete(self, url)
Get(self, url, parser)
Simplified interface for Get.
 
Requires a parser function which takes the server response's body as
the only argument.
 
Args:
  url: A string or something that can be converted to a string using str.
      The URL of the requested resource.
  parser: A function which takes the HTTP body from the server as it's
      only result. Common values would include str, 
      gdata.GDataEntryFromString, and gdata.GDataFeedFromString.
 
Returns: The result of calling parser(http_response_body).
Post(self, data, url, parser, media_source=None)
Streamlined version of Post.
 
Requires a parser function which takes the server response's body as
the only argument.
Put(self, data, url, parser, media_source=None)
Streamlined version of Put.
 
Requires a parser function which takes the server response's body as
the only argument.
__init__(self, application_name=None, tokens=None)

Methods inherited from gdata.service.GDataService:
AuthSubTokenInfo(self)
Fetches the AuthSub token's metadata from the server.
 
Raises:
  NonAuthSubToken if the user's auth token is not an AuthSub token
FetchOAuthRequestToken(self, scopes=None, extra_parameters=None, request_url='https://www.google.com/accounts/OAuthGetRequestToken')
Fetches OAuth request token and returns it.
 
Args:
  scopes: string or list of string base URL(s) of the service(s) to be
      accessed. If None, then this method tries to determine the
      scope(s) from the current service.
  extra_parameters: dict (optional) key-value pairs as any additional
      parameters to be included in the URL and signature while making a
      request for fetching an OAuth request token. All the OAuth parameters
      are added by default. But if provided through this argument, any
      default parameters will be overwritten. For e.g. a default parameter
      oauth_version 1.0 can be overwritten if
      extra_parameters = {'oauth_version': '2.0'}
  request_url: Request token URL. The default is
      'https://www.google.com/accounts/OAuthGetRequestToken'.
  
Returns:
  The fetched request token as a gdata.auth.OAuthToken object.
  
Raises:
  FetchingOAuthRequestTokenFailed if the server responded to the request
  with an error.
GenerateAuthSubURL(self, next, scope, secure=False, session=True, domain='default')
Generate a URL at which the user will login and be redirected back.
 
Users enter their credentials on a Google login page and a token is sent
to the URL specified in next. See documentation for AuthSub login at:
http://code.google.com/apis/accounts/docs/AuthSub.html
 
Args:
  next: string The URL user will be sent to after logging in.
  scope: string or list of strings. The URLs of the services to be 
         accessed.
  secure: boolean (optional) Determines whether or not the issued token
          is a secure token.
  session: boolean (optional) Determines whether or not the issued token
           can be upgraded to a session token.
GenerateOAuthAuthorizationURL(self, request_token=None, callback_url=None, extra_params=None, include_scopes_in_callback=False, scopes_param_prefix='oauth_token_scope', request_url='https://www.google.com/accounts/OAuthAuthorizeToken')
Generates URL at which user will login to authorize the request token.
 
Args:
  request_token: gdata.auth.OAuthToken (optional) OAuth request token.
      If not specified, then the current token will be used if it is of
      type <gdata.auth.OAuthToken>, else it is found by looking in the
      token_store by looking for a token for the current scope.    
  callback_url: string (optional) The URL user will be sent to after
      logging in and granting access.
  extra_params: dict (optional) Additional parameters to be sent.
  include_scopes_in_callback: Boolean (default=False) if set to True, and
      if 'callback_url' is present, the 'callback_url' will be modified to
      include the scope(s) from the request token as a URL parameter. The
      key for the 'callback' URL's scope parameter will be
      OAUTH_SCOPE_URL_PARAM_NAME. The benefit of including the scope URL as
      a parameter to the 'callback' URL, is that the page which receives
      the OAuth token will be able to tell which URLs the token grants
      access to.
  scopes_param_prefix: string (default='oauth_token_scope') The URL
      parameter key which maps to the list of valid scopes for the token.
      This URL parameter will be included in the callback URL along with
      the scopes of the token as value if include_scopes_in_callback=True.
  request_url: Authorization URL. The default is
      'https://www.google.com/accounts/OAuthAuthorizeToken'.
Returns:
  A string URL at which the user is required to login.
 
Raises:
  NonOAuthToken if the user's request token is not an OAuth token or if a
  request token was not available.
GetAuthSubToken(self)
Returns the AuthSub token as a string.
 
If the token is an gdta.auth.AuthSubToken, the Authorization Label
("AuthSub token") is removed.
 
This method examines the current_token to see if it is an AuthSubToken
or SecureAuthSubToken. If not, it searches the token_store for a token
which matches the current scope.
 
The current scope is determined by the service name string member.
 
Returns:
  If the current_token is set to an AuthSubToken/SecureAuthSubToken,
  return the token string. If there is no current_token, a token string
  for a token which matches the service object's default scope is returned.
  If there are no tokens valid for the scope, returns None.
GetClientLoginToken(self)
Returns the token string for the current token or a token matching the 
service scope.
 
If the current_token is a ClientLoginToken, the token string for 
the current token is returned. If the current_token is not set, this method
searches for a token in the token_store which is valid for the service 
object's current scope.
 
The current scope is determined by the service name string member.
The token string is the end of the Authorization header, it doesn not
include the ClientLogin label.
GetEntry(self, uri, extra_headers=None)
Query the GData API with the given URI and receive an Entry.
 
See also documentation for gdata.service.Get
 
Args:
  uri: string The query in the form of a URI. Example:
       '/base/feeds/snippets?bq=digital+camera'.
  extra_headers: dictionary (optional) Extra HTTP headers to be included
                 in the GET request. These headers are in addition to
                 those stored in the client's additional_headers property.
                 The client automatically sets the Content-Type and
                 Authorization headers.
 
Returns:
  A GDataEntry built from the XML in the server's response.
GetFeed(self, uri, extra_headers=None, converter=<function GDataFeedFromString at 0x7f03c9df7de8>)
Query the GData API with the given URI and receive a Feed.
 
See also documentation for gdata.service.Get
 
Args:
  uri: string The query in the form of a URI. Example:
       '/base/feeds/snippets?bq=digital+camera'.
  extra_headers: dictionary (optional) Extra HTTP headers to be included
                 in the GET request. These headers are in addition to
                 those stored in the client's additional_headers property.
                 The client automatically sets the Content-Type and
                 Authorization headers.
 
Returns:
  A GDataFeed built from the XML in the server's response.
GetMedia(self, uri, extra_headers=None)
Returns a MediaSource containing media and its metadata from the given
URI string.
GetNext(self, feed)
Requests the next 'page' of results in the feed.
 
This method uses the feed's next link to request an additional feed
and uses the class of the feed to convert the results of the GET request.
 
Args:
  feed: atom.Feed or a subclass. The feed should contain a next link and
      the type of the feed will be applied to the results from the 
      server. The new feed which is returned will be of the same class
      as this feed which was passed in.
 
Returns:
  A new feed representing the next set of results in the server's feed.
  The type of this feed will match that of the feed argument.
PostOrPut(self, verb, data, uri, extra_headers=None, url_params=None, escape_params=True, redirects_remaining=4, media_source=None, converter=None)
Insert data into a GData service at the given URI.
 
Args:
  verb: string, either 'POST' or 'PUT'
  data: string, ElementTree._Element, atom.Entry, or gdata.GDataEntry The
        XML to be sent to the uri. 
  uri: string The location (feed) to which the data should be inserted. 
       Example: '/base/feeds/items'. 
  extra_headers: dict (optional) HTTP headers which are to be included. 
                 The client automatically sets the Content-Type,
                 Authorization, and Content-Length headers.
  url_params: dict (optional) Additional URL parameters to be included
              in the URI. These are translated into query arguments
              in the form '&dict_key=value&...'.
              Example: {'max-results': '250'} becomes &max-results=250
  escape_params: boolean (optional) If false, the calling code has already
                 ensured that the query will form a valid URL (all
                 reserved characters have been escaped). If true, this
                 method will escape the query and any URL parameters
                 provided.
  media_source: MediaSource (optional) Container for the media to be sent
      along with the entry, if provided.
  converter: func (optional) A function which will be executed on the 
      server's response. Often this is a function like 
      GDataEntryFromString which will parse the body of the server's 
      response and return a GDataEntry.
 
Returns:
  If the post succeeded, this method will return a GDataFeed, GDataEntry,
  or the results of running converter on the server's result body (if
  converter was specified).
ProgrammaticLogin(self, captcha_token=None, captcha_response=None)
Authenticates the user and sets the GData Auth token.
 
Login retreives a temporary auth token which must be used with all
requests to GData services. The auth token is stored in the GData client
object.
 
Login is also used to respond to a captcha challenge. If the user's login
attempt failed with a CaptchaRequired error, the user can respond by
calling Login with the captcha token and the answer to the challenge.
 
Args:
  captcha_token: string (optional) The identifier for the captcha challenge
                 which was presented to the user.
  captcha_response: string (optional) The user's answer to the captch 
                    challenge.
 
Raises:
  CaptchaRequired if the login service will require a captcha response
  BadAuthentication if the login service rejected the username or password
  Error if the login service responded with a 403 different from the above
RevokeAuthSubToken(self)
Revokes an existing AuthSub token.
 
Raises:
  NonAuthSubToken if the user's auth token is not an AuthSub token
RevokeOAuthToken(self, request_url='https://www.google.com/accounts/AuthSubRevokeToken')
Revokes an existing OAuth token.
 
request_url: Token revoke URL. The default is
      'https://www.google.com/accounts/AuthSubRevokeToken'.
Raises:
  NonOAuthToken if the user's auth token is not an OAuth token.
  RevokingOAuthTokenFailed if request for revoking an OAuth token failed.
SetAuthSubToken(self, token, scopes=None, rsa_key=None)
Sets the token sent in requests to an AuthSub token.
 
Sets the current_token and attempts to add the token to the token_store.
 
Only use this method if you have received a token from the AuthSub
service. The auth token is set automatically when UpgradeToSessionToken()
is used. See documentation for Google AuthSub here:
http://code.google.com/apis/accounts/AuthForWebApps.html 
 
Args:
 token: gdata.auth.AuthSubToken or gdata.auth.SecureAuthSubToken or string
        The token returned by the AuthSub service. If the token is an
        AuthSubToken or SecureAuthSubToken, the scope information stored in
        the token is used. If the token is a string, the scopes parameter is
        used to determine the valid scopes.
 scopes: list of URLs for which the token is valid. This is only used
         if the token parameter is a string.
 rsa_key: string (optional) Private key required for RSA_SHA1 signature
          method.  This parameter is necessary if the token is a string
          representing a secure token.
SetClientLoginToken(self, token, scopes=None)
Sets the token sent in requests to a ClientLogin token.
 
This method sets the current_token to a new ClientLoginToken and it 
also attempts to add the ClientLoginToken to the token_store.
 
Only use this method if you have received a token from the ClientLogin
service. The auth_token is set automatically when ProgrammaticLogin()
is used. See documentation for Google ClientLogin here:
http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html
 
Args:
  token: string or instance of a ClientLoginToken.
SetOAuthInputParameters(self, signature_method, consumer_key, consumer_secret=None, rsa_key=None, two_legged_oauth=False)
Sets parameters required for using OAuth authentication mechanism.
 
NOTE: Though consumer_secret and rsa_key are optional, either of the two
is required depending on the value of the signature_method.
 
Args:
  signature_method: class which provides implementation for strategy class
      oauth.oauth.OAuthSignatureMethod. Signature method to be used for
      signing each request. Valid implementations are provided as the
      constants defined by gdata.auth.OAuthSignatureMethod. Currently
      they are gdata.auth.OAuthSignatureMethod.RSA_SHA1 and
      gdata.auth.OAuthSignatureMethod.HMAC_SHA1
  consumer_key: string Domain identifying third_party web application.
  consumer_secret: string (optional) Secret generated during registration.
      Required only for HMAC_SHA1 signature method.
  rsa_key: string (optional) Private key required for RSA_SHA1 signature
      method.
  two_legged_oauth: string (default=False) Enables two-legged OAuth process.
SetOAuthToken(self, oauth_token)
Attempts to set the current token and add it to the token store.
 
The oauth_token can be any OAuth token i.e. unauthorized request token,
authorized request token or access token.
This method also attempts to add the token to the token store.
Use this method any time you want the current token to point to the
oauth_token passed. For e.g. call this method with the request token
you receive from FetchOAuthRequestToken.
 
Args:
  request_token: gdata.auth.OAuthToken OAuth request token.
UpgradeToOAuthAccessToken(self, authorized_request_token=None, request_url='https://www.google.com/accounts/OAuthGetAccessToken', oauth_version='1.0')
Upgrades the authorized request token to an access token and returns it
 
Args:
  authorized_request_token: gdata.auth.OAuthToken (optional) OAuth request
      token. If not specified, then the current token will be used if it is
      of type <gdata.auth.OAuthToken>, else it is found by looking in the
      token_store by looking for a token for the current scope.
  oauth_version: str (default='1.0') oauth_version parameter. All other
      'oauth_' parameters are added by default. This parameter too, is
      added by default but here you can override it's value.
  request_url: Access token URL. The default is
      'https://www.google.com/accounts/OAuthGetAccessToken'.
 
Returns:
  Access token
      
Raises:
  NonOAuthToken if the user's authorized request token is not an OAuth
  token or if an authorized request token was not available.
  TokenUpgradeFailed if the server responded to the request with an 
  error.
UpgradeToSessionToken(self, token=None)
Upgrades a single use AuthSub token to a session token.
 
Args:
  token: A gdata.auth.AuthSubToken or gdata.auth.SecureAuthSubToken
         (optional) which is good for a single use but can be upgraded
         to a session token. If no token is passed in, the token
         is found by looking in the token_store by looking for a token
         for the current scope.
 
Raises:
  NonAuthSubToken if the user's auth token is not an AuthSub token
  TokenUpgradeFailed if the server responded to the request with an 
  error.
upgrade_to_session_token(self, token)
Upgrades a single use AuthSub token to a session token.
 
Args:
  token: A gdata.auth.AuthSubToken or gdata.auth.SecureAuthSubToken
         which is good for a single use but can be upgraded to a
         session token.
 
Returns:
  The upgraded token as a gdata.auth.AuthSubToken object.
 
Raises:
  TokenUpgradeFailed if the server responded to the request with an 
  error.

Data descriptors inherited from gdata.service.GDataService:
captcha_token
Get the captcha token for a login request.
captcha_url
Get the captcha URL for a login request.
source
The source is the name of the application making the request. 
It should be in the form company_id-app_name-app_version

Data and other attributes inherited from gdata.service.GDataService:
auth_token = None
handler = None
tokens = None

Methods inherited from atom.service.AtomService:
UseBasicAuth(self, username, password, for_proxy=False)
Sets an Authenticaiton: Basic HTTP header containing plaintext.
 
Deprecated, use use_basic_auth instead.
 
The username and password are base64 encoded and added to an HTTP header
which will be included in each request. Note that your username and 
password are sent in plaintext.
 
Args:
  username: str
  password: str
request(self, operation, url, data=None, headers=None, url_params=None)
use_basic_auth(self, username, password, scopes=None)

Data descriptors inherited from atom.service.AtomService:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
debug
If True, HTTP debug information is printed.
override_token

Data and other attributes inherited from atom.service.AtomService:
auto_set_current_token = True
auto_store_tokens = True
current_token = None
port = 80
ssl = False

 
class RedirectError(gdata.service.RequestError)
    
Method resolution order:
RedirectError
gdata.service.RequestError
gdata.service.Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from gdata.service.Error:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class UnableToUpgradeToken(Error)
    
Method resolution order:
UnableToUpgradeToken
Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from Error:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class Unauthorized(Error)
    
Method resolution order:
Unauthorized
Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from Error:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
Functions
       
create_converter(obj)
Experimental: Generates a converter function for this object's class.
 
When updating an entry, the returned object should usually be of the same
type as the original entry. Since the client's request method takes a
converter funtion as an argument, we need a function which will parse the
XML using the desired class.
 
Returns:
  A function which takes an XML string as the only parameter and returns an
  object of the same type as obj.
v2_entry_from_response(response)
Experimental converter which gets an Atom entry from the response.
v2_feed_from_response(response)
Experimental converter which gets an Atom feed from the response.

 
Data
        CLIENT_LOGIN_SCOPES = {'apps': ['http://www.google.com/a/feeds/', 'https://www.google.com/a/feeds/', 'http://apps-apis.google.com/a/feeds/', 'https://apps-apis.google.com/a/feeds/'], 'blogger': ['http://www.blogger.com/feeds/'], 'cl': ['https://www.google.com/calendar/feeds/', 'http://www.google.com/calendar/feeds/'], 'codesearch': ['http://www.google.com/codesearch/feeds/'], 'cp': ['https://www.google.com/m8/feeds/', 'http://www.google.com/m8/feeds/'], 'finance': ['http://finance.google.com/finance/feeds/'], 'gbase': ['http://base.google.com/base/feeds/', 'http://www.google.com/base/feeds/'], 'health': ['https://www.google.com/health/feeds/'], 'lh2': ['http://picasaweb.google.com/data/'], 'sitemaps': ['https://www.google.com/webmasters/tools/feeds/'], ...}
SCOPE_URL_PARAM_NAME = 'authsub_token_scope'
__author__ = 'j.s@google.com (Jeff Scudder)'

 
Author
        j.s@google.com (Jeff Scudder)