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
790 stars 194 forks source link

AttributeError: module 'msal' has no attribute 'telemetry' #357

Closed FelixHerold closed 3 years ago

FelixHerold commented 3 years ago

It seems like the "Implementing Telemetry V4" commit introduced the import msal.telemetry line. Unfortunately the file seems not to be loaded. Maybe try importing the function "_get_new_correlation_id" and class "_TelemetryContext" separatly.

rayluo commented 3 years ago

We could make some change here. Can you share a code snippet to reproduce this error? Currently it passes our tests.

python -c "import msal; print(msal.__version__, msal.PublicClientApplication)"
...  # There is no ImportError in the output
FelixHerold commented 3 years ago

Hello Ray Lua, and thank you for your quick answer. The error occurs already with the following dummy snippet: test_app=msal.ClientApplication(client_id="1") test_app.acquire_token_by_username_password(username="me", password="12345", scopes=[]) It shows: AttributeError: module 'msal' has no attribute 'telemetry' and seems to occur in the function "_build_telemetry_context". I am suing msal version 1.11.0 for Python 3.9.2. Regards Felix

Am 06-May-2021 19:47:58 +0200 schrieb @.***:

We could make some change here. Can you share a code snippet to reproduce this error? Currently it passes our tests.

python -c "import msal; print(msal.version, msal.PublicClientApplication)" ... # There is no ImportError in the output

-- You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.


FreeMail powered by mail.de - MEHR SICHERHEIT, SERIOSITÄT UND KOMFORT

rayluo commented 3 years ago

Can you paste your entire error stack trace, and also the output of pip list? Also, if possible, could you start a new virtual environment and test again? I tried your dummy script on my local machine and it still works. Also this is our test automation covering Python 3.9.

rayluo commented 3 years ago

Hi @FelixHerold , are you still actively working on this issue?

I worked out an experimental alternative. You can try it by first uninstall your existing msal pip uninstall msal, and then install the experimental version by pip install git+https://github.com/AzureAD/microsoft-authentication-library-for-python.git@relative-import-telemetry (by the way, this experimental version currently happens to have an older version number as 1.10.0, so you will know whether you install it successfully by a subsequent pip list).

Since I was not able to reproduce your issue in the first place, I can not guarantee this experiment would help solve the issue you encountered. Both the official MSAL 1.11.0 and this experimental version work on my machine. If you are willing to try the experimental version, please let us know the test result. We'd otherwise have to close this issue as invalid.

FelixHerold commented 3 years ago

Thank you for your help. I wasnt able to figure out why the error occurs in my code, but not in yours. I found a work around by importing all elements from telemetry one by one. I think it is ok to close this issue as invalid.

rayluo commented 3 years ago

Unable to reproduce.