Specify algorithm for jwt.decode

>>> jwt.decode(token, app.config["SECRET_KEY"])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/dist-packages/jwt/api_jwt.py", line 113, in decode
    decoded = self.decode_complete(jwt, key, algorithms, options, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/jwt/api_jwt.py", line 80, in decode_complete
    'It is required that you pass in a value for the "algorithms" argument when calling decode().'
jwt.exceptions.DecodeError: It is required that you pass in a value for the "algorithms" argument when calling decode().
This commit is contained in:
bl4ckh0l3z 2021-03-23 20:57:23 +01:00 committed by GitHub
parent a98679a923
commit 2f232bbc15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,7 +42,7 @@ def require_header_token(f):
def decorated(*args, **kwargs):
try:
token = request.headers['X-Token']
jwt.decode(token, app.config["SECRET_KEY"])
jwt.decode(token, app.config["SECRET_KEY"], "HS256")
return f(*args, **kwargs)
except:
return jsonify({"message": "JWT verification failed"})
@ -58,7 +58,7 @@ def require_get_token(f):
def decorated(*args, **kwargs):
try:
token = request.args.get("token")
jwt.decode(token, app.config["SECRET_KEY"])
jwt.decode(token, app.config["SECRET_KEY"], "HS256")
return f(*args, **kwargs)
except:
return jsonify({"message": "JWT verification failed"})