Closed yuqiuwen closed 7 months ago
Unable to catch it when raise errors, like DecodeError, InvalidTokenError, etc.
these errors are caught by flask error handler
return 422 http status code, and these errors are not caught by any hook function. { "msg": "Signature verification failed" }
{ "msg": "Signature verification failed" }
import jwt from jwt.exceptions import InvalidTokenError, DecodeError, InvalidSignatureError, ExpiredSignatureError @app.errorhandler(InvalidSignatureError) def handle_invalid_sign_error(error): app.logger.error(error) return make_response('invalid sign', code=Unauthorized.code) @app.errorhandler(InvalidTokenError) def handle_invalid_token_error(error): app.logger.error(error) return make_response('invalid token', code=Unauthorized.code) @app.errorhandler(ExpiredSignatureError) def handle_expire_sign_error(error): app.logger.error(error) return make_response('sign expired', code=Unauthorized.code) @app.errorhandler(DecodeError) def handle_decode_error(error): app.logger.error(error) return make_response('decode error', code=Unauthorized.code)
$ python -m jwt.help
{ "cryptography": { "version": "" }, "implementation": { "name": "CPython", "version": "3.9.17" }, "platform": { "release": "22.5.0", "system": "Darwin" }, "pyjwt": { "version": "2.8.0" } }
This command is only available on PyJWT v1.6.3 and greater. Otherwise, please provide some basic information about your system.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days
Unable to catch it when raise errors, like DecodeError, InvalidTokenError, etc.
Expected Result
these errors are caught by flask error handler
Actual Result
return 422 http status code, and these errors are not caught by any hook function.
{ "msg": "Signature verification failed" }
Reproduction Steps
System Information
This command is only available on PyJWT v1.6.3 and greater. Otherwise, please provide some basic information about your system.