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