1

我正在尝试运行

const credentials = await Auth.currentCredentials()
const creds = await Auth.essentialCredentials(credentials)
AWS.config.credentials = new AWS.Credentials(creds.accessKeyId, creds.secretAccessKey, creds.sessionToken)

但是第一行抛出 "cannot get guest credentials when mandatory signin enabled"

我的 Cognito 配置为仅适用于经过身份验证的用户。我不想允许未经身份验证的用户。我假设它无法找到登录用户的凭据,然后默认为来宾用户查找凭据——这些凭据不存在。

但是,当我运行时:

const s = await Auth.currentSession()
console.log(s)

或者

const s = await Auth.currentAuthenticatedUser()
console.log(s)

实际上,我看到了预期的响应,其中包含我使用 Amplify 登录屏幕登录的用户。在 currentSession 对象中,我有 idToken、refereshToken 和 accessToken,每个都包含 jwt 令牌。但不能从那里进步。

在 iOS 上运行并做出原生反应

有什么建议么?
谢谢

4

0 回答 0