Closed solsahar closed 8 months ago
Hrm... at a glance your code all looks ok. I'm pretty sure there isn't a bug with this extension, just due to how frequently it's being used and the test coverage around everything, but I wont rule it out.
Looking at the code in this extension:
create_access_token
creates a JWT with the type being access
(here)create_refresh_token
creates a JWT with the type being refresh
(here)config.access_cookie_name
(here and here)@jwt_required
is looking for a access
token by default (here)My first thought is that maybe the additional_claims
that you are passing in is overriding the JWT type
. Can you confirm what kind of data is being passed in there?
If you were able to make a minimal and reproducible example that I could run locally that reproduces this error, that would also go a long way towards tracking this down!
Thanks!
Hey! I finally figured out the issue. The issue was that when I refreshed the token, I passed the claims from the refresh token to the new access token. This overwrote the type and other information. Thank you for the help!
Hello! I'm trying to use Flask-JWT-Extended to set JWT tokens using cookies. I set the tokens like this:
I then have a protected method called at /layers defined like this:
On the front end, I noticed I was getting 422 UNPROCESSABLE ENTITY errors with a response json lookling like this:
{"msg":"Only non-refresh tokens are allowed"}
I was confused as to why this was happening, and after lots of debugging, I decided to turn to the source code. On line 361 of view_decorators.py, I added 2 new debug statements:
I noticed that in the decoded token, it seems that 'type' seems to always be refresh. I checked the encoded token, and confirmed that the encoded token is my access token (not refresh token).
Is this a bug? Am I doing it incorrectly?
Thank you!