def decorator(*args, **kwargs): token = None if 'Authorization' in request.headers: token = request.headers['Authorization'].split(' ')[1] if not token: return jsonify({'message': 'a valid token is missing'}) try: data = jwt.decode(token.encode('UTF-8'), 'SECRET', algorithm='HS256') print("logged in user is ") print(data) except Exception as e: print(e) return jsonify({'message': 'token is invalid'}) return f(*args, **kwargs)