DEV Community

Cover image for JWTManager object has no attribute token_in_blacklist_loader
HasOne
HasOne

Posted on

2 1

JWTManager object has no attribute token_in_blacklist_loader

If you're using this error:

AttributeError: 'JWTManager' object has no attribute 'token_in_blacklist_loader'
Enter fullscreen mode Exit fullscreen mode

it because you're using flask-jwt-extended version 4 and alot changed in version 4 you can see here. the token_in_blacklist_loader changed to token_in_blocklist_loader

how to overcome this issue

the recent migration to flask-jwt-extended made alot of improving and the following function now takes two arguments (jwt_header, jwt_payload):

@jwt.needs_fresh_token_loader
@jwt.revoked_token_loader
@jwt.user_lookup_loader
@jwt.user_lookup_error_loader
@jwt.expired_token_loader
@jwt.token_in_blocklist_loader
@jwt.token_verification_loader
@jwt.token_verification_failed_loader
Enter fullscreen mode Exit fullscreen mode

now you can fix the error and the jti is exist in jwt-payload:

@jwt.token_in_blocklist_loader
def check_if_token_in_blacklist(jwt_header, jwt_payload):
    jti = jwt_payload['jti']
    token_in_redis = jwt_redis_blacklist.get(jti)
    return token_in_redis is not False
Enter fullscreen mode Exit fullscreen mode

Thank you so much for reading! If you still see any issue, let me know!

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay