Skip to content

Commit 3c5f813

Browse files
committed
Merge pull request googleapis#18 from jay0lee/patch-1
Support the login_hint parameter
2 parents c4a3b62 + a319800 commit 3c5f813

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

oauth2client/client.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,7 @@ def __init__(self, client_id, client_secret, scope,
15081508
auth_uri=GOOGLE_AUTH_URI,
15091509
token_uri=GOOGLE_TOKEN_URI,
15101510
revoke_uri=GOOGLE_REVOKE_URI,
1511+
login_hint=None,
15111512
**kwargs):
15121513
"""Constructor for OAuth2WebServerFlow.
15131514
@@ -1530,13 +1531,17 @@ def __init__(self, client_id, client_secret, scope,
15301531
defaults to Google's endpoints but any OAuth 2.0 provider can be used.
15311532
revoke_uri: string, URI for revoke endpoint. For convenience
15321533
defaults to Google's endpoints but any OAuth 2.0 provider can be used.
1534+
login_hint: string, Either an email address or domain. Passing this hint
1535+
will either pre-fill the email box on the sign-in form or select the
1536+
proper multi-login session, thereby simplifying the login flow.
15331537
**kwargs: dict, The keyword arguments are all optional and required
15341538
parameters for the OAuth calls.
15351539
"""
15361540
self.client_id = client_id
15371541
self.client_secret = client_secret
15381542
self.scope = util.scopes_to_string(scope)
15391543
self.redirect_uri = redirect_uri
1544+
self.login_hint = login_hint
15401545
self.user_agent = user_agent
15411546
self.auth_uri = auth_uri
15421547
self.token_uri = token_uri
@@ -1574,6 +1579,8 @@ def step1_get_authorize_url(self, redirect_uri=None):
15741579
'redirect_uri': self.redirect_uri,
15751580
'scope': self.scope,
15761581
}
1582+
if self.login_hint is not None:
1583+
query_params['login_hint'] = self.login_hint
15771584
query_params.update(self.params)
15781585
return _update_query_params(self.auth_uri, query_params)
15791586

@@ -1656,7 +1663,7 @@ def step2_exchange(self, code, http=None):
16561663

16571664
@util.positional(2)
16581665
def flow_from_clientsecrets(filename, scope, redirect_uri=None,
1659-
message=None, cache=None):
1666+
message=None, cache=None, login_hint=None):
16601667
"""Create a Flow from a clientsecrets file.
16611668
16621669
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,
16741681
provided then clientsecrets.InvalidClientSecretsError will be raised.
16751682
cache: An optional cache service client that implements get() and set()
16761683
methods. See clientsecrets.loadfile() for details.
1684+
login_hint: string, Either an email address or domain. Passing this hint
1685+
will either pre-fill the email box on the sign-in form or select the
1686+
proper multi-login session, thereby simplifying the login flow.
16771687
16781688
Returns:
16791689
A Flow object.
@@ -1690,6 +1700,7 @@ def flow_from_clientsecrets(filename, scope, redirect_uri=None,
16901700
'redirect_uri': redirect_uri,
16911701
'auth_uri': client_info['auth_uri'],
16921702
'token_uri': client_info['token_uri'],
1703+
'login_hint': login_hint,
16931704
}
16941705
revoke_uri = client_info.get('revoke_uri')
16951706
if revoke_uri is not None:

0 commit comments

Comments
 (0)