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, login_hint=None, device_uri=GOOGLE_DEVICE_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
 
step1_get_device_and_user_codes(self, http=None)
Returns a user code and the verification URL where to enter it
source code
 
step2_exchange(self, code=None, http=None, device_flow_info=None)
Exchanges 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, login_hint=None, device_uri=GOOGLE_DEVICE_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.
  login_hint: string, Either an email address or domain. Passing this hint
    will either pre-fill the email box on the sign-in form or select the
    proper multi-login session, thereby simplifying the login flow.
  device_uri: string, URI for device authorization 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)

step1_get_device_and_user_codes(self, http=None)

source code 
Returns a user code and the verification URL where to enter it

Returns:
  A user code as a string for the user to authorize the application
  An URL as a string where the user has to enter the code

Decorators:
  • @util.positional(1)

step2_exchange(self, code=None, http=None, device_flow_info=None)

source code 
Exchanges a code for OAuth2Credentials.

Args:

  code: string, a dict-like object, or None. For a non-device
      flow, this is either the response code as a string, or a
      dictionary of query parameters to the redirect_uri. For a
      device flow, this should be None.
  http: httplib2.Http, optional http instance to use when fetching
      credentials.
  device_flow_info: DeviceFlowInfo, return value from step1 in the
      case of a device flow.

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

Raises:
  FlowExchangeError: if a problem occurred exchanging the code for a
      refresh_token.
  ValueError: if code and device_flow_info are both provided or both
      missing.

Decorators:
  • @util.positional(2)