Skip to content

3.16.0

Compare
Choose a tag to compare
@vimalloc vimalloc released this 20 Jan 18:43
· 250 commits to master since this release

This release changes how the @jwt.expired_token_loader callback function works. Before this release the callback function took no arguments. Now it will take one argument which is the decoded contents of the expired token. This lets you customize the expired token callback based on the token that was received. For example:

# Old way
@jwt.expired_token_loader
def old_expired_callback():
    return jsonify(foo='bar'), 401

# New way
@jwt.expired_token_loader
def new_expired_callback(expired_token):
    if expired_token['type'] == 'access':
        return jsonify(foo='bar'), 401
    else:
        return jsonify(foo='baz'), 401

The old way will still work, updating to this version will not break your software out from under you. You will however receive a deprecation warning when using that way. To fix this, simply add an addition argument to your callback function for the expired token.