fastapi-cloudauth icon indicating copy to clipboard operation
fastapi-cloudauth copied to clipboard

"not verified" response - cognito

Open JustinGuese opened this issue 2 years ago • 5 comments

Hi, maybe I am missing something obvious, but when authenticating using an auth token from cognito, the fastapi-cloudauth responds with 401 {"detail": "Not verified"}

This does not refer to the user I guess, as the user is email & phone verified, but does it refer to the domain (localhost, local dev)? How would I test my app locally then?

I hope you can point me in the right direction, as this package would be awesome to use!

JustinGuese avatar Jan 20 '22 09:01 JustinGuese

There are two types of token available in Cognito: IdToken and AccessToken. Make sure that you are using correct one.

tivaliy avatar Jan 23 '22 19:01 tivaliy

Can I check which of these is considered "correct"?

We've an API Gateway in front of an app. which uses fastapi-cloudauth and the Gateway seemingly accepts either. fastapi-cloudauth, however, seems only to accept the IdToken.

Not sure if I missed something in the docs as to why that would be or if it's configurable…?

PsypherPunk avatar Feb 24 '23 08:02 PsypherPunk

Ignore me: I RTFM'd a little harder and that first example finally clicked (AccessUser for the AccessToken; CognitoClaims for the IdToken.)

PsypherPunk avatar Feb 24 '23 08:02 PsypherPunk

I've implemented the code exactly as listed in the documentation for get_current_user, but regardless of if I pass the idToken or accessToken I still receive {detail: 'Not verified'}.

JLongley avatar Aug 04 '23 21:08 JLongley

@JLongley, can I check how you're getting the tokens? And how you're forming the requests?

I've just copy/pasted the example from the README and it's seemingly working for both ID and Access tokens.

PsypherPunk avatar Aug 08 '23 15:08 PsypherPunk