Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Signing in with AWS amplify on React Native

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.com/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.

like image 925
user1176516 Avatar asked Nov 29 '17 10:11

user1176516


1 Answers

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
    }
});
like image 72
Richard Zhang Avatar answered Sep 28 '22 05:09

Richard Zhang