Skip to content

Commit bb6d872

Browse files
committed
Warning when obsolete msal-extensions is detected
1 parent 53833ca commit bb6d872

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

msal/application.py

+17
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,21 @@ def obtain_token_by_username_password(self, username, password, **kwargs):
194194
username, password, headers=headers, **kwargs)
195195

196196

197+
def _msal_extension_check():
198+
# Can't run this in module or class level otherwise you'll get circular import error
199+
try:
200+
from msal_extensions import __version__ as v
201+
major, minor, _ = v.split(".", maxsplit=3)
202+
if not (int(major) >= 1 and int(minor) >= 2):
203+
warnings.warn(
204+
"Please upgrade msal-extensions. "
205+
"Only msal-extensions 1.2+ can work with msal 1.30+")
206+
except ImportError:
207+
pass # The optional msal_extensions is not installed. Business as usual.
208+
except ValueError:
209+
logger.exception(f"msal_extensions version {v} not in major.minor.patch format")
210+
211+
197212
class ClientApplication(object):
198213
"""You do not usually directly use this class. Use its subclasses instead:
199214
:class:`PublicClientApplication` and :class:`ConfidentialClientApplication`.
@@ -635,6 +650,8 @@ def __init__(
635650
self.authority_groups = None
636651
self._telemetry_buffer = {}
637652
self._telemetry_lock = Lock()
653+
_msal_extension_check()
654+
638655

639656
def _decide_broker(self, allow_broker, enable_pii_log):
640657
is_confidential_app = self.client_credential or isinstance(

0 commit comments

Comments
 (0)