AWS Cognito:Auth.signIn 中出现错误(验证 amazon-cognito-identity-js 已链接)

sou*_*bhs 5 amazon-web-services amazon-cognito react-native aws-amplify

我是 Amplify 与 Cognito 集成的新手,并且正在使用 Amplify 和 Cognito 进行身份验证来开发反应本机应用程序。我已在 AWS 控制台中配置用户池和联合身份。

我使用 React-navigation 5.x 版本创建了自己的注册和登录界面以及相应的屏幕。以下是我在package.json中添加的AWS相关模块

"@aws-amplify/auth": "^3.4.24",
"@aws-amplify/core": "^3.8.16",
Run Code Online (Sandbox Code Playgroud)

这是 App.js 中的 Amplify 配置

 Amplify.configure({ 
  Auth: { 
    identityPoolId: 'eu-west-2:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
    region: 'eu-west-2',
    userPoolId: 'eu-west-2_xxxxxxxx',
    userPoolWebClientId: 'xxxxxxxxxxxxxxxxxxxxxx',
    authenticationFlowType: 'USER_PASSWORD_AUTH'
  }
});
Run Code Online (Sandbox Code Playgroud)

我能够成功调用Auth.signUp,但在尝试调用Auth.signIn(用户名、密码)时出现错误

验证 amazon-cognito-identity-js 已链接

如何成功调用 Auth.signIn,请帮助解决问题?

小智 9

我遇到了同样的问题,我通过安装认知身份来解决它。运行以下命令:

npm i amazon-cognito-identity-js

安装后再次启动rn

npm start