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
754 stars 191 forks source link

[Bug] BaseBearerTokenAuthenticationProvider.authenticate_request does not refresh token with authorization header is present #670

Closed michaeldcanady closed 4 months ago

michaeldcanady commented 4 months ago

Describe the bug When authentication a request the method authenticate_request fails to refresh an expired JWT token.

To Reproduce Steps to reproduce the behavior:

  1. preform any graph request requiring a token
  2. verify request.headers has "authorization" key
  3. wait until bearer token is expired
  4. you will receive the following error "unable to parse claims from response" - upstream error due to having a bad token

Expected behavior once expired authenticate_request should retrieve a new token.

What you see instead Paste the sample output, or add screenshots to help explain your problem.

The MSAL Python version you are using Paste the output of this 1.26.0

Additional context Add any other context about the problem here.

rayluo commented 4 months ago

To Reproduce Steps to reproduce the behavior:

1. preform any graph request requiring a token

2. verify request.headers has "authorization" key

3. wait until bearer token is expired

4. you will receive the following error "unable to parse claims from response" - upstream error due to having a bad token

Hey, @michaeldcanady , in our bug template, the first step was "1. Go to our off-the-shelf samples and pick one that is closest to your usage scenario. You should not need to modify the sample." Can you share what sample you actually use, rather than just providing your high level steps? Just looking into your steps, it sounds like your app did not even attempt token refresh between your step 3 & 4. But our off-the-shelf samples should have already taken care of that.

michaeldcanady commented 4 months ago

Hey @rayluo! I put this on the wrong repo by mistake, I migrated the issue to https://github.com/microsoft/kiota-abstractions-python/issues/237, where it's applicable!