Closed max-programming closed 2 years ago
Instead of returning the username in the username
field of your token try using sub
. Also have a look here.
When authenticating, i.e. reading and parsing the token, fastapi-login
looks for the user identifier under the sub
(=subject) field, as this part of the official jwt rfc.
Works flawlessly! Thanks!
I am new to FastAPI and Python and I really like using this library. But for some reason it throws the invalid credentials error every time I try to request a protected route.
The thing is, I can log in successfully, I also get the token. But when I use that token as a bearer token in the header or use the FastAPI interface to send a request, it behaves the same.
I guess I might have done something wrong. This is my code.
Also the
query_user
function is markedasync
because I prev used my database to get the user but even when I tried it with dummy user, it still behaves the same.