javascript - Signing in with AWS amplify on React Native - Stack Overflow

I'm unable to get AWS Amplify to authenticate to my AWS Cognito setup. I use the following code to

I'm unable to get AWS Amplify to authenticate to my AWS Cognito setup. I use the following code to set up.

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'

    }
});

and this code to sign in

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

However I get the error No userPool logged as an error.

The example here: .md has some of the configuration attributes starting with a lower case, however when I follow that I get the Red Screen.

I'm unable to get AWS Amplify to authenticate to my AWS Cognito setup. I use the following code to set up.

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'

    }
});

and this code to sign in

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

However I get the error No userPool logged as an error.

The example here: https://github./aws/aws-amplify/blob/master/media/authentication_guide.md has some of the configuration attributes starting with a lower case, however when I follow that I get the Red Screen.

Share edited Dec 19, 2017 at 17:30 Adrian Hall 8,0351 gold badge20 silver badges26 bronze badges asked Nov 29, 2017 at 10:00 user1176516user1176516 1032 silver badges5 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

It is just wrong config. The example in guide is:

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
    }
});

I worked it out going through the AWS code, the userPoolWebClientId was required, and as Richard Zhang pointed out above I was using the wrong attributes.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745044794a4608029.html

相关推荐

  • javascript - Signing in with AWS amplify on React Native - Stack Overflow

    I'm unable to get AWS Amplify to authenticate to my AWS Cognito setup. I use the following code to

    8小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信