python-jose
python-jose copied to clipboard
Improve exceptions to provide feedback on which claim failed
Let's say my token fails to validate because my audience is incorrect.
https://github.com/mpdavis/python-jose/blob/be8e914a63e8940cd34ac0f5a066d114f10dad48/jose/jwt.py#L342-L350
With the above, it becomes non-trivial for me to do the following:
if failed because audience was wrong:
log("Expected audience was {expected} received {aud}")
# do something else
The problem is the same fo any other validation error.
PyJWT allows for easy distinction between failure modes, https://github.com/jpadilla/pyjwt/blob/db18661724305f7bc0663e738759222158900bb8/jwt/exceptions.py#L25