Merge pull request #18 from jay0lee/patch-1

Support the login_hint parameter
This commit is contained in:
Craig Citro
2014-06-20 09:04:58 -07:00

View File

@@ -1508,6 +1508,7 @@ class OAuth2WebServerFlow(Flow):
auth_uri=GOOGLE_AUTH_URI,
token_uri=GOOGLE_TOKEN_URI,
revoke_uri=GOOGLE_REVOKE_URI,
login_hint=None,
**kwargs):
"""Constructor for OAuth2WebServerFlow.
@@ -1530,6 +1531,9 @@ class OAuth2WebServerFlow(Flow):
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.
**kwargs: dict, The keyword arguments are all optional and required
parameters for the OAuth calls.
"""
@@ -1537,6 +1541,7 @@ class OAuth2WebServerFlow(Flow):
self.client_secret = client_secret
self.scope = util.scopes_to_string(scope)
self.redirect_uri = redirect_uri
self.login_hint = login_hint
self.user_agent = user_agent
self.auth_uri = auth_uri
self.token_uri = token_uri
@@ -1574,6 +1579,8 @@ class OAuth2WebServerFlow(Flow):
'redirect_uri': self.redirect_uri,
'scope': self.scope,
}
if self.login_hint is not None:
query_params['login_hint'] = self.login_hint
query_params.update(self.params)
return _update_query_params(self.auth_uri, query_params)
@@ -1656,7 +1663,7 @@ class OAuth2WebServerFlow(Flow):
@util.positional(2)
def flow_from_clientsecrets(filename, scope, redirect_uri=None,
message=None, cache=None):
message=None, cache=None, login_hint=None):
"""Create a Flow from a clientsecrets file.
Will create the right kind of Flow based on the contents of the clientsecrets
@@ -1674,6 +1681,9 @@ def flow_from_clientsecrets(filename, scope, redirect_uri=None,
provided then clientsecrets.InvalidClientSecretsError will be raised.
cache: An optional cache service client that implements get() and set()
methods. See clientsecrets.loadfile() for details.
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.
Returns:
A Flow object.
@@ -1690,6 +1700,7 @@ def flow_from_clientsecrets(filename, scope, redirect_uri=None,
'redirect_uri': redirect_uri,
'auth_uri': client_info['auth_uri'],
'token_uri': client_info['token_uri'],
'login_hint': login_hint,
}
revoke_uri = client_info.get('revoke_uri')
if revoke_uri is not None: