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:
		@@ -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"})
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user