Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

User pools for users who register via twitter?

I'm new to Cognito. So I need some clarification about how I should be registering users who have signed up via a social login.

I've created both a user pool and a federated identity pool.

Then I performed a basic oauth request to twitter upon the user's login button click, and then with the twitter token and secret that I receive after successfully logging them in, I perform a request to get Cognito Identity credentials.

var params = {
  IdentityPoolId: 'my-pool-id',
  Logins: {
    'api.twitter.com': userToken+";"+userSecret
  }
};

// initialize the Credentials object with our parameters
AWS.config.credentials = new AWS.CognitoIdentityCredentials(params);
AWS.config.credentials.get(function(err) {
    if (err) {
        console.log("Error: "+err);
        return;
    }
    console.log("Cognito Identity Id: " + AWS.config.credentials.identityId);

    // Other service clients will automatically use the Cognito Credentials provider
    // configured in the JavaScript SDK.
    var cognitoSyncClient = new AWS.CognitoSync();
    cognitoSyncClient.listDatasets({
        IdentityId: AWS.config.credentials.identityId,
        IdentityPoolId: params.IdentityPoolId
    }, function(err, data) {
        if ( !err ) {
            console.log("success", JSON.stringify(data));
        } else {
      console.log("cognito error", err);
    }
 });

And then I get a successful response with a cognito identity Id, and a list of datasets for that user.

Should I also be registering that user in a user pool too? the documentation for this product is kinda disjointed when it comes to the concept of social login.

like image 604
Kristian Avatar asked Oct 17 '22 20:10

Kristian


1 Answers

User Pools put very simply is just there to act as a database of users for your application. It's for people that don't want to have to manage a database to store their users login data, among other things.

User Pools is an identity provider, just like Google, Facebook, Twitter etc.

If you wish to only allow users to log into your application with Twitter credentials then you have no need for User Pools.

Only consider using User Pools, if you're looking to create a managed database of your user's information.

https://aws.amazon.com/blogs/aws/new-user-pools-for-amazon-cognito/

like image 186
Rob Devereux Avatar answered Oct 20 '22 11:10

Rob Devereux