AzureAD / microsoft-authentication-library-for-python

Microsoft Authentication Library (MSAL) for Python makes it easy to authenticate to Microsoft Entra ID. General docs are available here https://learn.microsoft.com/entra/msal/python/ Stable APIs are documented here https://msal-python.readthedocs.io. Questions can be asked on www.stackoverflow.com with tag "msal" + "python".
https://stackoverflow.com/questions/tagged/azure-ad-msal+python
Other
770 stars 192 forks source link

Lazy load dependencies #454

Closed rayluo closed 2 years ago

rayluo commented 2 years ago

Lazy load MSAL's dependencies. This resolves #423.

Also remove an old workaround. P.S.: @xiangyan99, after this change, the Azure Identity 1.3.* and 1.4 versions are expected to throw this exception:

AttributeError: module 'msal.authority' has no attribute 'requests'
jiasli commented 2 years ago

Actually Azure CLI already lazily imports MSAL. The issue #423 is only a (possibly not appropriate) suggestion.

I am not sure how much this change will benefit other MSAL users, who use the default requests HTTP client. But yea, lazy import requests is certainly beneficial to users how choose to use their own HTTP client.

rayluo commented 2 years ago

Actually Azure CLI already lazily imports MSAL. The issue #423 is only a (possibly not appropriate) suggestion.

I am not sure how much this change will benefit other MSAL users, who use the default requests HTTP client. But yea, lazy import requests is certainly beneficial to users how choose to use their own HTTP client.

It turns out, lazy loading our dependencies makes MSAL easier to be used in some restricted environment. So, we will still ship this.

jiasli commented 2 years ago

Could you share more info about "restricted environment"? If requests is not required, perhaps we need to tweak

https://github.com/AzureAD/microsoft-authentication-library-for-python/blob/636a58ccb4e000335ae251cc374bdc17baa68fc2/setup.py#L75