Reputation: 69
I am trying to implement refresh token system in flask_jwt_extended, I followed official documentation. When I try to get new access_token with refresh_token using postman I get the response with new access token. But when I try with axios call it is throwing 401 error saying:
msg: "Missing Authorization Header"
my flask code:
@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)
below is my axios api call:
getAPI.post('/refresh', {
// refresh_token: context.state.refreshToken,
headers: { Authorization: `Bearer ${context.state.refreshToken}` },
})
axios api call:
{"headers":{"Authorization":"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTYxNzY0MDcyOCwianRpIjoiNmE3OTYyNjctNjYwMS00ZjQ5LWJmZjEtODUwYjhhMDkyMjgyIiwibmJmIjoxNjE3NjQwNzI4LCJ0eXBlIjoicmVmcmVzaCIsInN1YiI6eyJlbWFpbCI6InZlbjMzQGVtYWlsLmNvbSIsImFkZGl0aW9uYWxfY2xhaW1zIjp7InJvbGUiOltbIlVzZXIiXV19fSwiZXhwIjoxNjIwMjMyNzI4fQ.5MoE8DXwO7cCwN5nVC1u1st0cm1LDhBu1nSDb7VJmgg"}}
Upvotes: 0
Views: 645