|
7 | 7 | import time |
8 | 8 | import uuid |
9 | 9 |
|
| 10 | +from .application import __version__ |
| 11 | + |
10 | 12 |
|
11 | 13 | logger = logging.getLogger(__name__) |
12 | 14 |
|
13 | | -from .application import ( |
14 | | - __version__) |
15 | 15 |
|
16 | 16 | try: |
17 | 17 | import pymsalruntime # Its API description is available in site-packages/pymsalruntime/PyMsalRuntime.pyi |
@@ -139,18 +139,19 @@ def _get_new_correlation_id(): |
139 | 139 | def _enable_msa_pt(params): |
140 | 140 | params.set_additional_parameter("msal_request_type", "consumer_passthrough") # PyMsalRuntime 0.8+ |
141 | 141 |
|
142 | | -def _pass_client_sku(params): |
143 | | - params.set_additional_parameter("msal_client_sku", "MSAL.Python") |
144 | | - params.set_additional_parameter("msal_client_ver", __version__) |
| 142 | +def _build_msal_runtime_auth_params(client_id, authority): |
| 143 | + params = pymsalruntime.MSALRuntimeAuthParameters(client_id, authority) |
| 144 | + params.set_additional_parameter("msal_client_sku", "MSAL.Python") |
| 145 | + params.set_additional_parameter("msal_client_ver", __version__) |
| 146 | + return params |
145 | 147 |
|
146 | 148 | def _signin_silently( |
147 | 149 | authority, client_id, scopes, correlation_id=None, claims=None, |
148 | 150 | enable_msa_pt=False, |
149 | 151 | auth_scheme=None, |
150 | 152 | **kwargs): |
151 | | - params = pymsalruntime.MSALRuntimeAuthParameters(client_id, authority) |
| 153 | + params = _build_msal_runtime_auth_params(client_id, authority) |
152 | 154 | params.set_requested_scopes(scopes) |
153 | | - _pass_client_sku(params) |
154 | 155 | if claims: |
155 | 156 | params.set_decoded_claims(claims) |
156 | 157 | if auth_scheme: |
@@ -182,9 +183,8 @@ def _signin_interactively( |
182 | 183 | enable_msa_pt=False, |
183 | 184 | auth_scheme=None, |
184 | 185 | **kwargs): |
185 | | - params = pymsalruntime.MSALRuntimeAuthParameters(client_id, authority) |
| 186 | + params = _build_msal_runtime_auth_params(client_id, authority) |
186 | 187 | params.set_requested_scopes(scopes) |
187 | | - _pass_client_sku(params) |
188 | 188 | params.set_redirect_uri( |
189 | 189 | _redirect_uri_on_mac if sys.platform == "darwin" else |
190 | 190 | "https://login.microsoftonline.com/common/oauth2/nativeclient" |
@@ -239,9 +239,8 @@ def _acquire_token_silently( |
239 | 239 | account = _read_account_by_id(account_id, correlation_id) |
240 | 240 | if account is None: |
241 | 241 | return |
242 | | - params = pymsalruntime.MSALRuntimeAuthParameters(client_id, authority) |
| 242 | + params = _build_msal_runtime_auth_params(client_id, authority) |
243 | 243 | params.set_requested_scopes(scopes) |
244 | | - _pass_client_sku(params) |
245 | 244 | if claims: |
246 | 245 | params.set_decoded_claims(claims) |
247 | 246 | if auth_scheme: |
|
0 commit comments