@@ -84,28 +84,31 @@ def _acquire_token_silent(app):
84
84
85
85
def _acquire_token_interactive (app , scopes = None , data = None ):
86
86
"""acquire_token_interactive() - User will be prompted if app opts to do select_account."""
87
+ scopes = scopes or _input_scopes () # Let user input scope param before less important prompt and login_hint
87
88
prompt = _select_options ([
88
89
{"value" : None , "description" : "Unspecified. Proceed silently with a default account (if any), fallback to prompt." },
89
90
{"value" : "none" , "description" : "none. Proceed silently with a default account (if any), or error out." },
90
91
{"value" : "select_account" , "description" : "select_account. Prompt with an account picker." },
91
92
],
92
93
option_renderer = lambda o : o ["description" ],
93
94
header = "Prompt behavior?" )["value" ]
94
- raw_login_hint = _select_options (
95
- # login_hint is unnecessary when prompt=select_account,
96
- # but we still let tester input login_hint, just for testing purpose.
97
- [None ] + [a ["username" ] for a in app .get_accounts ()],
98
- header = "login_hint? (If you have multiple signed-in sessions in browser/broker, and you specify a login_hint to match one of them, you will bypass the account picker.)" ,
99
- accept_nonempty_string = True ,
100
- )
101
- login_hint = raw_login_hint ["username" ] if isinstance (raw_login_hint , dict ) else raw_login_hint
95
+ if prompt == "select_account" :
96
+ login_hint = None # login_hint is unnecessary when prompt=select_account
97
+ else :
98
+ raw_login_hint = _select_options (
99
+ [None ] + [a ["username" ] for a in app .get_accounts ()],
100
+ header = "login_hint? (If you have multiple signed-in sessions in browser/broker, and you specify a login_hint to match one of them, you will bypass the account picker.)" ,
101
+ accept_nonempty_string = True ,
102
+ )
103
+ login_hint = raw_login_hint ["username" ] if isinstance (raw_login_hint , dict ) else raw_login_hint
102
104
result = app .acquire_token_interactive (
103
- scopes or _input_scopes () ,
105
+ scopes ,
104
106
parent_window_handle = app .CONSOLE_WINDOW_HANDLE , # This test app is a console app
105
107
enable_msa_passthrough = app .client_id in [ # Apps are expected to set this right
106
108
_AZURE_CLI , _VISUAL_STUDIO ,
107
109
], # Here this test app mimics the setting for some known MSA-PT apps
108
- prompt = prompt , login_hint = login_hint , data = data or {})
110
+ prompt = prompt , login_hint = login_hint , data = data or {},
111
+ )
109
112
if login_hint and "id_token_claims" in result :
110
113
signed_in_user = result .get ("id_token_claims" , {}).get ("preferred_username" )
111
114
if signed_in_user != login_hint :
0 commit comments