@@ -37,7 +37,7 @@ def _input_scopes():
37
37
"User.Read" ,
38
38
"User.ReadBasic.All" ,
39
39
],
40
- header = "Select a scope (multiple scopes can only be input by manually typing them):" ,
40
+ header = "Select a scope (multiple scopes can only be input by manually typing them, delimited by space ):" ,
41
41
accept_nonempty_string = True ,
42
42
).split ()
43
43
@@ -62,13 +62,23 @@ def acquire_token_silent(app):
62
62
force_refresh = _input_boolean ("Bypass MSAL Python's token cache?" ),
63
63
))
64
64
65
+ def _acquire_token_interactive (app , scopes , data = None ):
66
+ return app .acquire_token_interactive (
67
+ scopes ,
68
+ prompt = _select_options ([
69
+ {"value" : None , "description" : "Unspecified. Proceed silently with a default account (if any), fallback to prompt." },
70
+ {"value" : "none" , "description" : "none. Proceed silently with a default account (if any), or error out." },
71
+ {"value" : "select_account" , "description" : "select_account. Prompt with an account picker." },
72
+ ],
73
+ option_renderer = lambda o : o ["description" ],
74
+ header = "Prompt behavior?" )["value" ],
75
+ login_hint = _input ("login_hint (typically an email address, or leave it blank if you don't need one): " ) or None ,
76
+ data = data or {},
77
+ )
78
+
65
79
def acquire_token_interactive (app ):
66
80
"""acquire_token_interactive() - User will be prompted if app opts to do select_account."""
67
- pprint .pprint (app .acquire_token_interactive (
68
- _input_scopes (),
69
- prompt = "select_account" if _input_boolean ("Select Account?" ) else None ,
70
- login_hint = _input ("login_hint: " ) or None ,
71
- ))
81
+ pprint .pprint (_acquire_token_interactive (app , _input_scopes ()))
72
82
73
83
def acquire_token_by_username_password (app ):
74
84
"""acquire_token_by_username_password() - See constraints here: https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows#constraints-for-ropc"""
@@ -95,12 +105,7 @@ def acquire_ssh_cert_silently(app):
95
105
96
106
def acquire_ssh_cert_interactive (app ):
97
107
"""Acquire an SSH Cert interactively - This typically only works with Azure CLI"""
98
- result = app .acquire_token_interactive (
99
- SSH_CERT_SCOPE ,
100
- prompt = "select_account" if _input_boolean ("Select Account?" ) else None ,
101
- login_hint = _input ("login_hint: " ) or None ,
102
- data = SSH_CERT_DATA ,
103
- )
108
+ result = _acquire_token_interactive (app , SSH_CERT_SCOPE , data = SSH_CERT_DATA )
104
109
pprint .pprint (result )
105
110
if result .get ("token_type" ) != "ssh-cert" :
106
111
logging .error ("Unable to acquire an ssh-cert" )
@@ -118,9 +123,9 @@ def exit(_):
118
123
sys .exit ()
119
124
120
125
def main ():
121
- print ("Welcome to the Msal Python Console Test App" )
126
+ print ("Welcome to the Msal Python Console Test App, committed at 2022-5-2 \n " )
122
127
chosen_app = _select_options ([
123
- {"client_id" : "04b07795-8ddb-461a-bbee-02f9e1bf7b46" , "name" : "Azure CLI" },
128
+ {"client_id" : "04b07795-8ddb-461a-bbee-02f9e1bf7b46" , "name" : "Azure CLI (Correctly configured for MSA-PT) " },
124
129
{"client_id" : "04f0c124-f2bc-4f59-8241-bf6df9866bbd" , "name" : "Visual Studio (Correctly configured for MSA-PT)" },
125
130
],
126
131
option_renderer = lambda a : a ["name" ],
@@ -134,7 +139,10 @@ def main():
134
139
"https://login.microsoftonline.com/microsoft.onmicrosoft.com" ,
135
140
"https://login.microsoftonline.com/msidlab4.onmicrosoft.com" ,
136
141
"https://login.microsoftonline.com/consumers" ,
137
- ], header = "Input authority" , accept_nonempty_string = True ),
142
+ ],
143
+ header = "Input authority (Note that MSA-PT apps would NOT use the /common authority)" ,
144
+ accept_nonempty_string = True ,
145
+ ),
138
146
)
139
147
if _input_boolean ("Enable MSAL Python's DEBUG log?" ):
140
148
logging .basicConfig (level = logging .DEBUG )
0 commit comments