Skip to content

Fetching current_user failure and and a possible solution #25

Open
@pknag

Description

@pknag

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions