0

jwtを処理するためにpythonフラスコ_jwt_extendedを使用しています。次のように(ドキュメントから)更新エンドポイントがあります。

# 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

フロントエンドでこのエンドポイントを呼び出すタイミングがわかりません。保護されたエンドポイントを使用しようとすると、次のようになります (これは予期されることです)。

{
  "msg": "Token has expired"
}

フロントエンドで有効期限が切れる前にトークンを更新する方法をどのように知る必要がありますか?

4

1 に答える 1