Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions msal/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,21 @@ def obtain_token_by_username_password(self, username, password, **kwargs):
username, password, headers=headers, **kwargs)


def _msal_extension_check():
# Can't run this in module or class level otherwise you'll get circular import error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice comment! Makes things clear.

try:
from msal_extensions import __version__ as v
major, minor, _ = v.split(".", maxsplit=3)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. In fact, msal-extensions used to also use packaging.version but have since removed it in https://github.com/AzureAD/microsoft-authentication-extensions-for-python/pull/125.

if not (int(major) >= 1 and int(minor) >= 2):
warnings.warn(
"Please upgrade msal-extensions. "
"Only msal-extensions 1.2+ can work with msal 1.30+")
except ImportError:
pass # The optional msal_extensions is not installed. Business as usual.
except ValueError:
logger.exception(f"msal_extensions version {v} not in major.minor.patch format")


class ClientApplication(object):
"""You do not usually directly use this class. Use its subclasses instead:
:class:`PublicClientApplication` and :class:`ConfidentialClientApplication`.
Expand Down Expand Up @@ -635,6 +650,8 @@ def __init__(
self.authority_groups = None
self._telemetry_buffer = {}
self._telemetry_lock = Lock()
_msal_extension_check()


def _decide_broker(self, allow_broker, enable_pii_log):
is_confidential_app = self.client_credential or isinstance(
Expand Down