Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning when obsolete msal-extensions is detected #752

Merged
merged 1 commit into from
Sep 26, 2024
Merged

Conversation

rayluo
Copy link
Collaborator

@rayluo rayluo commented Sep 26, 2024

The lengthy discussion in "Updates to msal/application.py may now be out-of-sync with msal_extensions"
#745
considered a mitigation of introducing a new optional dependency msal[extensions] for MSAL. However, after offline discussion, we believe it has two drawbacks: (1) it is hardly discoverable for most msal-extensions users, and (2) it introduces a permanent "msal[extensions]" declaration only for trivial gain.

So, we ended up settling on an alternative. MSAL will now detect the msal-extensions from the current environment. If its version is lower than 1.2.0, MSAL will emit a warning like this:

/.../msal/application.py:203: UserWarning: Please upgrade msal-extensions. Only msal-extensions 1.2+ can work with msal 1.30+

This PR will close #745 .

CC @jiasli , @kcphila

@rayluo rayluo requested a review from a team as a code owner September 26, 2024 06:08
# Can't run this in module or class level otherwise you'll get circular import error
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
Collaborator 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.

@@ -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.

@rayluo rayluo merged commit bb6d872 into dev Sep 26, 2024
12 checks passed
@rayluo rayluo deleted the msal-extensions-check branch September 26, 2024 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Updates to msal/application.py may now be out-of-sync with msal_extensions
2 participants