From 2f232bbc15d5f77d7e2e53fe6fac3a9d20e128db Mon Sep 17 00:00:00 2001 From: bl4ckh0l3z Date: Tue, 23 Mar 2021 20:57:23 +0100 Subject: [PATCH] Specify algorithm for jwt.decode >>> jwt.decode(token, app.config["SECRET_KEY"]) Traceback (most recent call last): File "", line 1, in 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(). --- server/backend/app/decorators.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/backend/app/decorators.py b/server/backend/app/decorators.py index c48041f..dc23255 100644 --- a/server/backend/app/decorators.py +++ b/server/backend/app/decorators.py @@ -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"})