flask jwt 扩展刷新令牌抛出错误
throwing error for flask jwt extended refresh token
我正在尝试在 flask_jwt_extended 中实现刷新令牌系统,我遵循了官方文档。当我尝试使用邮递员使用 refresh_token 获取新的 access_token 时,我得到了带有新访问令牌的响应。但是当我尝试使用 axios 调用时,它抛出 401 错误说:
msg: "Missing Authorization Header"
我的烧瓶代码:
@app.route("/refresh", methods=["POST"])
@jwt_required(refresh=True)
def refresh():
identity = get_jwt_identity()
print(identity)
access_token = create_access_token(identity=identity)
return jsonify(access_token=access_token)
print(access_token)
下面是我的 axios api 调用:
getAPI.post('/refresh', {
// refresh_token: context.state.refreshToken,
headers: { Authorization: `Bearer ${context.state.refreshToken}` },
})
axios api 调用:
{"headers":{"Authorization":"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTYxNzY0MDcyOCwianRpIjoiNmE3OTYyNjctNjYwMS00ZjQ5LWJmZjEtODUwYjhhMDkyMjgyIiwibmJmIjoxNjE3NjQwNzI4LCJ0eXBlIjoicmVmcmVzaCIsInN1YiI6eyJlbWFpbCI6InZlbjMzQGVtYWlsLmNvbSIsImFkZGl0aW9uYWxfY2xhaW1zIjp7InJvbGUiOltbIlVzZXIiXV19fSwiZXhwIjoxNjIwMjMyNzI4fQ.5MoE8DXwO7cCwN5nVC1u1st0cm1LDhBu1nSDb7VJmgg"}}
'POST' flask_extended 的调用配置选项应该在第三个参数中。原答案由github.
提供
getAPI.post('/refresh', {
{},
headers: { Authorization: `Bearer ${context.state.refreshToken}` },
})
我正在尝试在 flask_jwt_extended 中实现刷新令牌系统,我遵循了官方文档。当我尝试使用邮递员使用 refresh_token 获取新的 access_token 时,我得到了带有新访问令牌的响应。但是当我尝试使用 axios 调用时,它抛出 401 错误说:
msg: "Missing Authorization Header"
我的烧瓶代码:
@app.route("/refresh", methods=["POST"])
@jwt_required(refresh=True)
def refresh():
identity = get_jwt_identity()
print(identity)
access_token = create_access_token(identity=identity)
return jsonify(access_token=access_token)
print(access_token)
下面是我的 axios api 调用:
getAPI.post('/refresh', {
// refresh_token: context.state.refreshToken,
headers: { Authorization: `Bearer ${context.state.refreshToken}` },
})
axios api 调用:
{"headers":{"Authorization":"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTYxNzY0MDcyOCwianRpIjoiNmE3OTYyNjctNjYwMS00ZjQ5LWJmZjEtODUwYjhhMDkyMjgyIiwibmJmIjoxNjE3NjQwNzI4LCJ0eXBlIjoicmVmcmVzaCIsInN1YiI6eyJlbWFpbCI6InZlbjMzQGVtYWlsLmNvbSIsImFkZGl0aW9uYWxfY2xhaW1zIjp7InJvbGUiOltbIlVzZXIiXV19fSwiZXhwIjoxNjIwMjMyNzI4fQ.5MoE8DXwO7cCwN5nVC1u1st0cm1LDhBu1nSDb7VJmgg"}}
'POST' flask_extended 的调用配置选项应该在第三个参数中。原答案由github.
提供getAPI.post('/refresh', {
{},
headers: { Authorization: `Bearer ${context.state.refreshToken}` },
})