Open pknag opened 6 months ago
In number of methods in the code current_user is fetched like this:
user_id = current_user["sub"] if current_user != None else None
If a user is logged this fails with error:
line 96, in get_current_user raise RuntimeError( RuntimeError: You must provide a@jwt.user_lookup_loadercallback to use this method
line 96, in get_current_user raise RuntimeError( RuntimeError: You must provide a
callback to use this method
My solution is to add the callback method in api/__init__.py right after JWTManager is initialized like this:
api/__init__.py
jwt = JWTManager(app) @jwt.user_lookup_loader def user_lookup_callback(_jwt_header, jwt_data): return jwt_data
I am using python==3.11, Flask==2.2.2, Flask-JWT-Extended==4.4.4 as per requirements.txt.
In number of methods in the code current_user is fetched like this:
user_id = current_user["sub"] if current_user != None else None
If a user is logged this fails with error:
line 96, in get_current_user raise RuntimeError( RuntimeError: You must provide a
@jwt.user_lookup_loadercallback to use this method
My solution is to add the callback method in
api/__init__.py
right after JWTManager is initialized like this:I am using python==3.11, Flask==2.2.2, Flask-JWT-Extended==4.4.4 as per requirements.txt.