Skip to content

Commit 63bb27f

Browse files
committed
Updated in warning placement
1 parent 3576183 commit 63bb27f

2 files changed

Lines changed: 12 additions & 13 deletions

File tree

msal/application.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,17 @@ def get_client_assertion():
715715
self._region_detected = None
716716
self.client, self._regional_client = self._build_client(
717717
client_credential, self.authority)
718+
# Warn if using a static string/bytes client_assertion (discouraged for long-running apps)
719+
if client_credential and isinstance(client_credential.get("client_assertion"), (str, bytes)):
720+
warnings.warn(
721+
"Passing a static string/bytes 'client_assertion' is "
722+
"discouraged because the JWT will eventually expire. "
723+
"Pass a no-arg callable instead (optionally wrapped in "
724+
"msal.AutoRefresher) so MSAL can obtain a fresh "
725+
"assertion on demand. "
726+
"See https://github.com/AzureAD/microsoft-authentication-library-for-python/issues/746",
727+
DeprecationWarning, stacklevel=2)
728+
718729
self.authority_groups = {}
719730
self._telemetry_buffer = {}
720731
self._telemetry_lock = Lock()
@@ -846,19 +857,6 @@ def _build_client(self, client_credential, authority, skip_regional_client=False
846857
# so that we can ignore an empty string came from an empty ENV VAR.
847858
if client_credential.get("client_assertion"):
848859
client_assertion = client_credential['client_assertion']
849-
if not callable(client_assertion):
850-
# Soft-deprecation: a fixed string assertion has a fixed
851-
# expiration. Long-running apps should pass a callable so
852-
# MSAL can fetch a fresh assertion on demand. See
853-
# https://github.com/AzureAD/microsoft-authentication-library-for-python/issues/746
854-
warnings.warn(
855-
"Passing a static string/bytes 'client_assertion' is "
856-
"discouraged because the JWT will eventually expire. "
857-
"Pass a no-arg callable instead (optionally wrapped in "
858-
"msal.AutoRefresher) so MSAL can obtain a fresh "
859-
"assertion on demand. "
860-
"See https://github.com/AzureAD/microsoft-authentication-library-for-python/issues/746",
861-
DeprecationWarning, stacklevel=2)
862860
else:
863861
headers = {}
864862
sha1_thumbprint = sha256_thumbprint = None

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ broker =
6363
# most existing MSAL Python apps do not have the redirect_uri needed by broker.
6464
#
6565
# We need pymsalruntime.CallbackData introduced in PyMsalRuntime 0.14
66+
# Using >=0.20 to accept all 0.20.x releases that include required features
6667
pymsalruntime>=0.20,<0.21; python_version>='3.9' and platform_system=='Windows'
6768
# On Mac, PyMsalRuntime 0.17+ is expected to support SSH cert and ROPC
6869
pymsalruntime>=0.20,<0.21; python_version>='3.9' and platform_system=='Darwin'

0 commit comments

Comments
 (0)