I am working with python flask_jwt_extended to handle jwt. I have a refresh endpoint (from the docs) as follows:
# The jwt_refresh_token_required decorator insures a valid refresh
# token is present in the request before calling this endpoint. We
# can use the get_jwt_identity() function to get the identity of
# the refresh token, and use the create_access_token() function again
# to make a new access token for this identity.
@app.route('/refresh', methods=['POST'])
@jwt_refresh_token_required
def refresh():
current_user = get_jwt_identity()
ret = {
'access_token': create_access_token(identity=current_user)
}
return jsonify(ret), 200
I am unsure when I am supposed to call this endpoint in my front end. When I try to use a protected endpoint I get the following (this is expected):
{
"msg": "Token has expired"
}
How am I supposed to know to refresh the token before expiry on the front end and how would it do so?