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

Class OAuth2WebServerFlow

source code


Does the Web Server Flow for OAuth 2.0.

OAuth2WebServerFlow objects may be safely pickled and unpickled.

Instance Methods [hide private]
 
__init__(self, client_id, client_secret, scope, redirect_uri=None, user_agent=None, auth_uri=GOOGLE_AUTH_URI, token_uri=GOOGLE_TOKEN_URI, revoke_uri=GOOGLE_REVOKE_URI, **kwargs)
Constructor for OAuth2WebServerFlow.
source code
 
step1_get_authorize_url(self, redirect_uri=None)
Returns a URI to redirect to the provider.
source code
 
step2_exchange(self, code, http=None)
Exhanges a code for OAuth2Credentials.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, client_id, client_secret, scope, redirect_uri=None, user_agent=None, auth_uri=GOOGLE_AUTH_URI, token_uri=GOOGLE_TOKEN_URI, revoke_uri=GOOGLE_REVOKE_URI, **kwargs)
(Constructor)

source code 
Constructor for OAuth2WebServerFlow.

The kwargs argument is used to set extra query parameters on the
auth_uri. For example, the access_type and approval_prompt
query parameters can be set via kwargs.

Args:
  client_id: string, client identifier.
  client_secret: string client secret.
  scope: string or iterable of strings, scope(s) of the credentials being
    requested.
  redirect_uri: string, Either the string 'urn:ietf:wg:oauth:2.0:oob' for
    a non-web-based application, or a URI that handles the callback from
    the authorization server.
  user_agent: string, HTTP User-Agent to provide for this application.
  auth_uri: string, URI for authorization endpoint. For convenience
    defaults to Google's endpoints but any OAuth 2.0 provider can be used.
  token_uri: string, URI for token endpoint. For convenience
    defaults to Google's endpoints but any OAuth 2.0 provider can be used.
  revoke_uri: string, URI for revoke endpoint. For convenience
    defaults to Google's endpoints but any OAuth 2.0 provider can be used.
  **kwargs: dict, The keyword arguments are all optional and required
                    parameters for the OAuth calls.

Decorators:
  • @util.positional(4)
Overrides: object.__init__

step1_get_authorize_url(self, redirect_uri=None)

source code 
Returns a URI to redirect to the provider.

Args:
  redirect_uri: string, Either the string 'urn:ietf:wg:oauth:2.0:oob' for
    a non-web-based application, or a URI that handles the callback from
    the authorization server. This parameter is deprecated, please move to
    passing the redirect_uri in via the constructor.

Returns:
  A URI as a string to redirect the user to begin the authorization flow.

Decorators:
  • @util.positional(1)

step2_exchange(self, code, http=None)

source code 
Exhanges a code for OAuth2Credentials.

Args:
  code: string or dict, either the code as a string, or a dictionary
    of the query parameters to the redirect_uri, which contains
    the code.
  http: httplib2.Http, optional http instance to use to do the fetch

Returns:
  An OAuth2Credentials object that can be used to authorize requests.

Raises:
  FlowExchangeError if a problem occured exchanging the code for a
  refresh_token.

Decorators:
  • @util.positional(2)