Reputation: 974
I am trying to run
const credentials = await Auth.currentCredentials()
const creds = await Auth.essentialCredentials(credentials)
AWS.config.credentials = new AWS.Credentials(creds.accessKeyId, creds.secretAccessKey, creds.sessionToken)
But first line throws
"cannot get guest credentials when mandatory signin enabled"
My Cognito is configured to work only for authenticated users. I don't want to allow unauthenticated users. I assume it can't find credentials for the logged in user, then defaults to find credentials for guest user - which don't exist.
However when I run:
const s = await Auth.currentSession()
console.log(s)
or
const s = await Auth.currentAuthenticatedUser()
console.log(s)
Indeed I see the expected response, containing the user I signed in with Amplify log in screen. In currentSession object I have idToken, refereshToken and accessToken, each containing jwt token. But can't progress from there.
Running on iOS and react native
Any suggestions?
Thanks
Upvotes: 1
Views: 2629
Reputation: 11
You need to enable it by updating your Auth configuration in AWS Amplify by using the following instructions:
Use the CLI command "amplify update auth".
Select Walkthrough auth settings.
Go through some of steps until you are asked whether to enable unauthenticated logins. Enable it.
Go through more steps until no more questions.
Finally, use the CLI command "amplify push".
This should allow you to access let Auth.currentCredentials() and will add an unauthenticated login on your identity pool.
Upvotes: 0