@@ -104,6 +104,16 @@ def _get_new_correlation_id():
104
104
return str (uuid .uuid4 ())
105
105
106
106
107
+ def _enable_msa_pt_when_needed (params , client_id ):
108
+ if client_id in [ # Experimental: Automatically enable MSA-PT mode for known MSA-PT apps
109
+ # More background of MSA-PT is available from this internal docs:
110
+ # https://microsoft.sharepoint.com/:w:/t/Identity-DevEx/EatIUauX3c9Ctw1l7AQ6iM8B5CeBZxc58eoQCE0IuZ0VFw?e=tgc3jP&CID=39c853be-76ea-79d7-ee73-f1b2706ede05
111
+ "04b07795-8ddb-461a-bbee-02f9e1bf7b46" , # Azure CLI
112
+ "04f0c124-f2bc-4f59-8241-bf6df9866bbd" , # Visual Studio
113
+ ]:
114
+ params .set_additional_parameter ("msal_request_type" , "consumer_passthrough" ) # PyMsalRuntime 0.8+
115
+
116
+
107
117
def _signin_silently (authority , client_id , scopes , correlation_id = None , claims = None , ** kwargs ):
108
118
params = pymsalruntime .MSALRuntimeAuthParameters (client_id , authority )
109
119
params .set_requested_scopes (scopes )
@@ -113,6 +123,7 @@ def _signin_silently(authority, client_id, scopes, correlation_id=None, claims=N
113
123
for k , v in kwargs .items (): # This can be used to support domain_hint, max_age, etc.
114
124
if v is not None :
115
125
params .set_additional_parameter (k , str (v ))
126
+ _enable_msa_pt_when_needed (params , client_id )
116
127
pymsalruntime .signin_silently (
117
128
params ,
118
129
correlation_id or _get_new_correlation_id (),
@@ -145,6 +156,7 @@ def _signin_interactively(
145
156
logger .warning ("Using both select_account and login_hint is ambiguous. Ignoring login_hint." )
146
157
else :
147
158
logger .warning ("prompt=%s is not supported by this module" , prompt )
159
+ _enable_msa_pt_when_needed (params , client_id )
148
160
for k , v in kwargs .items (): # This can be used to support domain_hint, max_age, etc.
149
161
if v is not None :
150
162
params .set_additional_parameter (k , str (v ))
0 commit comments