@@ -84,28 +84,31 @@ def _acquire_token_silent(app):
8484
8585def _acquire_token_interactive (app , scopes = None , data = None ):
8686 """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
8788 prompt = _select_options ([
8889 {"value" : None , "description" : "Unspecified. Proceed silently with a default account (if any), fallback to prompt." },
8990 {"value" : "none" , "description" : "none. Proceed silently with a default account (if any), or error out." },
9091 {"value" : "select_account" , "description" : "select_account. Prompt with an account picker." },
9192 ],
9293 option_renderer = lambda o : o ["description" ],
9394 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
102104 result = app .acquire_token_interactive (
103- scopes or _input_scopes () ,
105+ scopes ,
104106 parent_window_handle = app .CONSOLE_WINDOW_HANDLE , # This test app is a console app
105107 enable_msa_passthrough = app .client_id in [ # Apps are expected to set this right
106108 _AZURE_CLI , _VISUAL_STUDIO ,
107109 ], # 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+ )
109112 if login_hint and "id_token_claims" in result :
110113 signed_in_user = result .get ("id_token_claims" , {}).get ("preferred_username" )
111114 if signed_in_user != login_hint :
0 commit comments