Skip to content

Commit 96614ec

Browse files
committed
Precise DeprecationWarning for auth code API
1 parent 770690b commit 96614ec

File tree

1 file changed

+32
-24
lines changed

1 file changed

+32
-24
lines changed

msal/application.py

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -441,16 +441,20 @@ def get_authorization_request_url(
441441
{"authorization_endpoint": the_authority.authorization_endpoint},
442442
self.client_id,
443443
http_client=self.http_client)
444-
return client.build_auth_request_uri(
445-
response_type=response_type,
446-
redirect_uri=redirect_uri, state=state, login_hint=login_hint,
447-
prompt=prompt,
448-
scope=decorate_scope(scopes, self.client_id),
449-
nonce=nonce,
450-
domain_hint=domain_hint,
451-
claims=_merge_claims_challenge_and_capabilities(
452-
self._client_capabilities, claims_challenge),
453-
)
444+
warnings.warn(
445+
"Change your get_authorization_request_url() "
446+
"to initiate_auth_code_flow()", DeprecationWarning)
447+
with warnings.catch_warnings(record=True):
448+
return client.build_auth_request_uri(
449+
response_type=response_type,
450+
redirect_uri=redirect_uri, state=state, login_hint=login_hint,
451+
prompt=prompt,
452+
scope=decorate_scope(scopes, self.client_id),
453+
nonce=nonce,
454+
domain_hint=domain_hint,
455+
claims=_merge_claims_challenge_and_capabilities(
456+
self._client_capabilities, claims_challenge),
457+
)
454458

455459
def acquire_token_by_auth_code_flow(
456460
self, auth_code_flow, auth_response, scopes=None, **kwargs):
@@ -572,20 +576,24 @@ def acquire_token_by_authorization_code(
572576
# really empty.
573577
assert isinstance(scopes, list), "Invalid parameter type"
574578
self._validate_ssh_cert_input_data(kwargs.get("data", {}))
575-
return self.client.obtain_token_by_authorization_code(
576-
code, redirect_uri=redirect_uri,
577-
scope=decorate_scope(scopes, self.client_id),
578-
headers={
579-
CLIENT_REQUEST_ID: _get_new_correlation_id(),
580-
CLIENT_CURRENT_TELEMETRY: _build_current_telemetry_request_header(
581-
self.ACQUIRE_TOKEN_BY_AUTHORIZATION_CODE_ID),
582-
},
583-
data=dict(
584-
kwargs.pop("data", {}),
585-
claims=_merge_claims_challenge_and_capabilities(
586-
self._client_capabilities, claims_challenge)),
587-
nonce=nonce,
588-
**kwargs)
579+
warnings.warn(
580+
"Change your acquire_token_by_authorization_code() "
581+
"to acquire_token_by_auth_code_flow()", DeprecationWarning)
582+
with warnings.catch_warnings(record=True):
583+
return self.client.obtain_token_by_authorization_code(
584+
code, redirect_uri=redirect_uri,
585+
scope=decorate_scope(scopes, self.client_id),
586+
headers={
587+
CLIENT_REQUEST_ID: _get_new_correlation_id(),
588+
CLIENT_CURRENT_TELEMETRY: _build_current_telemetry_request_header(
589+
self.ACQUIRE_TOKEN_BY_AUTHORIZATION_CODE_ID),
590+
},
591+
data=dict(
592+
kwargs.pop("data", {}),
593+
claims=_merge_claims_challenge_and_capabilities(
594+
self._client_capabilities, claims_challenge)),
595+
nonce=nonce,
596+
**kwargs)
589597

590598
def get_accounts(self, username=None):
591599
"""Get a list of accounts which previously signed in, i.e. exists in cache.

0 commit comments

Comments
 (0)