Package oauth2client :: Module client :: Class AccessTokenCredentials |
[hide private]
[frames] | no frames]

# Class AccessTokenCredentials

source code

    Credentials object for OAuth 2.0.

    Credentials can be applied to an httplib2.Http object using the
    authorize() method, which then signs each request from that object
    with the OAuth 2.0 access token. This set of credentials is for the
    use case where you have acquired an OAuth 2.0 access_token from
    another place such as a JavaScript client or another web
    application, and wish to use it from Python. Because only the
    access_token is present it can not be refreshed and will in time
    expire.

    AccessTokenCredentials objects may be safely pickled and unpickled.

    Usage:
      credentials = AccessTokenCredentials('<an access token>',
        'my-user-agent/1.0')
      http = httplib2.Http()
      http = credentials.authorize(http)

    Exceptions:
      AccessTokenCredentialsExpired: raised when the access_token expires or is
        revoked.

Instance Methods | [hide private]
__init__(self, access_token, user_agent, revoke_uri=None) Create an instance of OAuth2Credentials | source code
_refresh(self, http_request) Refreshes the access_token. | source code
_revoke(self, http_request) Revokes the access_token and deletes the store if available. | source code
Inherited from `OAuth2Credentials`: `__getstate__`, `__setstate__`, `access_token_expired`, `apply`, `authorize`, `refresh`, `revoke`, `set_store`, `to_json` Inherited from `OAuth2Credentials` (private): `_do_refresh_request`, `_do_revoke`, `_generate_refresh_request_body`, `_generate_refresh_request_headers`, `_updateFromCredential` Inherited from `Credentials` (private): `_to_json` Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Class Methods | [hide private]
from_json(cls, s) Instantiate a Credentials object from a JSON description of it. | source code
Inherited from `Credentials`: `new_from_json`

Class Variables | [hide private]
Inherited from `Credentials`: `NON_SERIALIZED_MEMBERS`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, access_token, user_agent, revoke_uri=None) (Constructor) | source code
    Create an instance of OAuth2Credentials

    This is one of the few types if Credentials that you should contrust,
    Credentials objects are usually instantiated by a Flow.

    Args:
      access_token: string, access token.
      user_agent: string, The HTTP User-Agent to provide for this application.
      revoke_uri: string, URI for revoke endpoint. Defaults to None; a token
        can't be revoked if this is None.
Overrides: object.__init__

### from_json(cls, s) Class Method | source code
    Instantiate a Credentials object from a JSON description of it. The JSON
    should have been produced by calling .to_json() on the object.

    Args:
      data: dict, A deserialized JSON object.

    Returns:
      An instance of a Credentials subclass.
Overrides: Credentials.from_json (inherited documentation)

### _refresh(self, http_request) | source code
    Refreshes the access_token.

    This method first checks by reading the Storage object if available.
    If a refresh is still needed, it holds the Storage lock until the
    refresh is completed.

    Args:
      http_request: callable, a callable that matches the method signature of
        httplib2.Http.request, used to make the refresh request.

    Raises:
      AccessTokenRefreshError: When the refresh fails.
Overrides: OAuth2Credentials._refresh (inherited documentation)

### _revoke(self, http_request) | source code
    Revokes the access_token and deletes the store if available.

    Args:
      http_request: callable, a callable that matches the method signature of
        httplib2.Http.request, used to make the revoke request.
Overrides: OAuth2Credentials._revoke