繁体   English   中英

使用AWS登录放大React Native

[英]Signing in with AWS amplify on React Native

我无法让AWS Amplify对我的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

但是我收到错误没有userPool记录为错误。

这里的示例: https//github.com/aws/aws-amplify/blob/master/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在上面指出的那样,我使用了错误的属性。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM