Skip to content

Commit 363af6d

Browse files
committed
Merge branch 'prompt-constants' into dev
2 parents 9492022 + cbba052 commit 363af6d

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

oauth2cli/oidc.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,19 @@ def _nonce_hash(nonce):
8383
return hashlib.sha256(nonce.encode("ascii")).hexdigest()
8484

8585

86+
class Prompt(object):
87+
"""This class defines the constant strings for prompt parameter.
88+
89+
The values are based on
90+
https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest
91+
"""
92+
NONE = "none"
93+
LOGIN = "login"
94+
CONSENT = "consent"
95+
SELECT_ACCOUNT = "select_account"
96+
CREATE = "create" # Defined in https://openid.net/specs/openid-connect-prompt-create-1_0.html#PromptParameter
97+
98+
8699
class Client(oauth2.Client):
87100
"""OpenID Connect is a layer on top of the OAuth2.
88101
@@ -217,6 +230,8 @@ def obtain_token_by_browser(
217230
`OIDC <https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest>`_.
218231
:param string prompt: Defined in
219232
`OIDC <https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest>`_.
233+
You can find the valid string values defined in :class:`oidc.Prompt`.
234+
220235
:param int max_age: Defined in
221236
`OIDC <https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest>`_.
222237
:param string ui_locales: Defined in
@@ -232,7 +247,7 @@ def obtain_token_by_browser(
232247
for descriptions on other parameters and return value.
233248
"""
234249
filtered_params = {k:v for k, v in dict(
235-
prompt=prompt,
250+
prompt=" ".join(prompt) if isinstance(prompt, (list, tuple)) else prompt,
236251
display=display,
237252
max_age=max_age,
238253
ui_locales=ui_locales,

0 commit comments

Comments
 (0)