fastapi-users
fastapi-users copied to clipboard
500 Response on jwt.exception.ExpiredSignatureError
Describe the bug
When using the oauth_router, the state jwt token has an expiration time.
When the callback tries to call the callback endpoint with an expired state token, an Internal Server Error (500) is thrown because the jwt.ExpiredSignatureError is thrown, however only the jwt.DecodeError case is handled in the code.
To Reproduce
- Call the
oauth_routers/authorizeendpoint. - Wait for the
statetoken to expire. - Call the
/callbackwith an otherwise valid request (except for an expired token). - See error
Expected behavior
When calling the callback endpoint with an Invalid token:
400 BAD REQUEST or similar, should be the response instead of 500
Solution Proposal
Catch jwt.InvalidTokenError instead of just jwt.DecodeError.