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

Unable to verify the token signature of a token received by the msal-typescript library #20

Open
exhuma opened this issue Feb 18, 2024 · 0 comments

Comments

@exhuma
Copy link

exhuma commented Feb 18, 2024

I use the msal typescript library to retrieve a token. I can use the token to access the graph-api from microsoft.

But I can't use the token to access my own fast-api endpoints. It always fails with an error on signature verification. What am I missing?

I added some logging and am seeing this:

Signature verification failed.
Traceback (most recent call last):
  File "/workspaces/backend/env/lib/python3.11/site-packages/jose/jws.py", line 262, in _verify_signature
    raise JWSSignatureError()
jose.exceptions.JWSSignatureError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/workspaces/backend/env/lib/python3.11/site-packages/jose/jwt.py", line 142, in decode
    payload = jws.verify(token, key, algorithms, verify=verify_signature)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/backend/env/lib/python3.11/site-packages/jose/jws.py", line 73, in verify
    _verify_signature(signing_input, header, signature, key, algorithms)
  File "/workspaces/backend/env/lib/python3.11/site-packages/jose/jws.py", line 264, in _verify_signature
    raise JWSError("Signature verification failed.")
jose.exceptions.JWSError: Signature verification failed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/workspaces/backend/env/lib/python3.11/site-packages/fastapi_microsoft_identity/auth_service.py", line 192, in __decode_JWT
    payload = jwt.decode(
              ^^^^^^^^^^^
  File "/workspaces/backend/env/lib/python3.11/site-packages/jose/jwt.py", line 144, in decode
    raise JWTError(e)
jose.exceptions.JWTError: Signature verification failed.
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

No branches or pull requests

1 participant