mercredi 25 août 2021

Authentication not working when using /token route instead of authorize button in Swagger UI in FastAPI

Following the docs about implementing OAuth2 with JWT in FastAPI I can't seem to get the authentication working within Swagger UI when using the /token route instead of the authorize button. Why is this the case?

I copy pasted the same code in the docs and tried to fill in the request body fields username and password of the /token route instead of doing so using the authorize button. Then when I try to use route /users/me I get :

{
  "detail": "Not authenticated"
}

My thought is that my Frontend written in something like React for example would make a POST request to the /token route to authenticate. However if the token route doesn't work and the only way to properly authenticate is by using the Authorize button of the Swagger UI then this is a major problem.




Aucun commentaire:

Enregistrer un commentaire