Signing in with AWS amplify on React Native



我无法使AWS放大以对我的AWS Cognito设置进行身份验证。我使用以下代码进行设置。

import Amplify from 'aws-amplify-react-native';
import { Auth } from 'aws-amplify-react-native';
Amplify.configure({
    Auth: {
        IdentityPoolId: 'us-west-2:XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
        region: 'us-west-2',
        UserPoolId: 'us-west-2_XXXXXXXX',
        ClientId: 'XXXXXXXXXXXXXXX'
    }
});

和此代码要签名

Auth.signIn(this.state.username, this.state.password)
.then(user => console.log(user))
.catch(err => console.log(err)); //"No userPool" logged here

但是,我得到错误 no userpool 记录为错误。

此处的示例:https://github.com/aws/aws-amplify/blob/master/media/media/authentication_guide.md具有一些以较低的情况开头的配置属性红屏。

这只是错误的配置。指南中的示例是:

import Amplify from 'aws-amplify';
Amplify.configure({
    Auth: {
        identityPoolId: 'XX-XXXX-X:XXXXXXXX-XXXX-1234-abcd-1234567890ab', //REQUIRED - Amazon Cognito Identity Pool ID
        region: 'XX-XXXX-X', // REQUIRED - Amazon Cognito Region
        userPoolId: 'XX-XXXX-X_abcd1234', //OPTIONAL - Amazon Cognito User Pool ID
        userPoolWebClientId: 'XX-XXXX-X_abcd1234', //OPTIONAL - Amazon Cognito Web Client ID
    }
});

我浏览了AWS代码,需要使用UserPoolWebClientID,并且正如Richard Zhang在上面指出的那样,我使用了错误的属性。

相关内容

  • 没有找到相关文章

最新更新