apiclient.oauth
index
/home/jcgregorio/projects/google-api-python-client/apiclient/oauth.py

Utilities for OAuth.
 
Utilities for making it easier to work with OAuth.

 
Modules
       
copy
httplib2
logging
oauth2
json
urllib
urlparse

 
Classes
       
exceptions.Exception(exceptions.BaseException)
Error
CredentialsInvalidError
MissingParameter
RequestError
oauth2client.client.Credentials(__builtin__.object)
OAuthCredentials
TwoLeggedOAuthCredentials
oauth2client.client.Flow(__builtin__.object)
FlowThreeLegged

 
class CredentialsInvalidError(Error)
    
Method resolution order:
CredentialsInvalidError
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>
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)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
class Error(exceptions.Exception)
    Base error for this module.
 
 
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>
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)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
class FlowThreeLegged(oauth2client.client.Flow)
    Does the Three Legged Dance for OAuth 1.0a.
 
 
Method resolution order:
FlowThreeLegged
oauth2client.client.Flow
__builtin__.object

Methods defined here:
__init__(self, discovery, consumer_key, consumer_secret, user_agent, **kwargs)
discovery       - Section of the API discovery document that describes
                  the OAuth endpoints.
consumer_key    - OAuth consumer key
consumer_secret - OAuth consumer secret
user_agent      - The HTTP User-Agent that identifies the application.
**kwargs        - The keyword arguments are all optional and required
                  parameters for the OAuth calls.
step1_get_authorize_url(self, oauth_callback='oob')
Returns a URI to redirect to the provider.
 
oauth_callback - Either the string 'oob' for a non-web-based application,
                 or a URI that handles the callback from the authorization
                 server.
 
If oauth_callback is 'oob' then pass in the
generated verification code to step2_exchange,
otherwise pass in the query parameters received
at the callback uri to step2_exchange.
step2_exchange(self, verifier)
Exhanges an authorized request token
for OAuthCredentials.
 
Args:
  verifier: string, dict - either the verifier token, or a dictionary
    of the query parameters to the callback, which contains
    the oauth_verifier.
Returns:
   The Credentials object.

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

 
class MissingParameter(Error)
    
Method resolution order:
MissingParameter
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>
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)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
class OAuthCredentials(oauth2client.client.Credentials)
    Credentials object for OAuth 1.0a
 
 
Method resolution order:
OAuthCredentials
oauth2client.client.Credentials
__builtin__.object

Methods defined here:
__getstate__(self)
Trim the state down to something that can be pickled.
__init__(self, consumer, token, user_agent)
consumer   - An instance of oauth.Consumer.
token      - An instance of oauth.Token constructed with
             the access token and secret.
user_agent - The HTTP User-Agent to provide for this application.
__setstate__(self, state)
Reconstitute the state of the object from being pickled.
authorize(self, http)
Authorize an httplib2.Http instance with these Credentials
 
Args:
   http - An instance of httplib2.Http
       or something that acts like it.
 
Returns:
   A modified instance of http that was passed in.
 
Example:
 
  h = httplib2.Http()
  h = credentials.authorize(h)
 
You can't create a new OAuth
subclass of httplib2.Authenication because
it never gets passed the absolute URI, which is
needed for signing. So instead we have to overload
'request' with a closure that adds in the
Authorization header and then calls the original version
of 'request()'.
set_store(self, store)
Set the storage for the credential.
 
Args:
  store: callable, a callable that when passed a Credential
    will store the credential back to where it came from.
    This is needed to store the latest access_token if it
    has been revoked.

Data descriptors defined here:
invalid
True if the credentials are invalid, such as being revoked.

Methods inherited from oauth2client.client.Credentials:
apply(self, headers)
Add the authorization to the headers.
 
Args:
  headers: dict, the headers to add the Authorization header to.
refresh(self, http)
Forces a refresh of the access_token.
 
Args:
  http: httplib2.Http, an http object to be used to make the refresh
    request.
to_json(self)
Creating a JSON representation of an instance of Credentials.
 
Returns:
   string, a JSON representation of this instance, suitable to pass to
   from_json().

Class methods inherited from oauth2client.client.Credentials:
new_from_json(cls, s) from __builtin__.type
Utility class method to instantiate a Credentials subclass from a JSON
representation produced by to_json().
 
Args:
  s: string, JSON from to_json().
 
Returns:
  An instance of the subclass of Credentials that was serialized with
  to_json().

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

Data and other attributes inherited from oauth2client.client.Credentials:
NON_SERIALIZED_MEMBERS = ['store']

 
class RequestError(Error)
    Error occurred during request.
 
 
Method resolution order:
RequestError
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>
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)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
class TwoLeggedOAuthCredentials(oauth2client.client.Credentials)
    Two Legged Credentials object for OAuth 1.0a.
 
The Two Legged object is created directly, not from a flow.  Once you
authorize and httplib2.Http instance you can change the requestor and that
change will propogate to the authorized httplib2.Http instance. For example:
 
  http = httplib2.Http()
  http = credentials.authorize(http)
 
  credentials.requestor = 'foo@example.info'
  http.request(...)
  credentials.requestor = 'bar@example.info'
  http.request(...)
 
 
Method resolution order:
TwoLeggedOAuthCredentials
oauth2client.client.Credentials
__builtin__.object

Methods defined here:
__getstate__(self)
Trim the state down to something that can be pickled.
__init__(self, consumer_key, consumer_secret, user_agent)
Args:
  consumer_key: string, An OAuth 1.0 consumer key
  consumer_secret: string, An OAuth 1.0 consumer secret
  user_agent: string, The HTTP User-Agent to provide for this application.
__setstate__(self, state)
Reconstitute the state of the object from being pickled.
authorize(self, http)
Authorize an httplib2.Http instance with these Credentials
 
Args:
   http - An instance of httplib2.Http
       or something that acts like it.
 
Returns:
   A modified instance of http that was passed in.
 
Example:
 
  h = httplib2.Http()
  h = credentials.authorize(h)
 
You can't create a new OAuth
subclass of httplib2.Authenication because
it never gets passed the absolute URI, which is
needed for signing. So instead we have to overload
'request' with a closure that adds in the
Authorization header and then calls the original version
of 'request()'.
getrequestor(self)
set_store(self, store)
Set the storage for the credential.
 
Args:
  store: callable, a callable that when passed a Credential
    will store the credential back to where it came from.
    This is needed to store the latest access_token if it
    has been revoked.
setrequestor(self, email)

Data descriptors defined here:
invalid
True if the credentials are invalid, such as being revoked.
 
Always returns False for Two Legged Credentials.
requestor
The email address of the user to act on behalf of

Methods inherited from oauth2client.client.Credentials:
apply(self, headers)
Add the authorization to the headers.
 
Args:
  headers: dict, the headers to add the Authorization header to.
refresh(self, http)
Forces a refresh of the access_token.
 
Args:
  http: httplib2.Http, an http object to be used to make the refresh
    request.
to_json(self)
Creating a JSON representation of an instance of Credentials.
 
Returns:
   string, a JSON representation of this instance, suitable to pass to
   from_json().

Class methods inherited from oauth2client.client.Credentials:
new_from_json(cls, s) from __builtin__.type
Utility class method to instantiate a Credentials subclass from a JSON
representation produced by to_json().
 
Args:
  s: string, JSON from to_json().
 
Returns:
  An instance of the subclass of Credentials that was serialized with
  to_json().

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

Data and other attributes inherited from oauth2client.client.Credentials:
NON_SERIALIZED_MEMBERS = ['store']

 
Data
        __author__ = 'jcgregorio@google.com (Joe Gregorio)'

 
Author
        jcgregorio@google.com (Joe Gregorio)