Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetching current_user failure and and a possible solution #25

Open
pknag opened this issue Mar 12, 2024 · 0 comments
Open

Fetching current_user failure and and a possible solution #25

pknag opened this issue Mar 12, 2024 · 0 comments

Comments

@pknag
Copy link

pknag commented Mar 12, 2024

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:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant