User pools for users who register via twitter?

I am new to Cognito. Therefore, I need to clarify how I should register users who have registered through a social input.

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

Then I fulfilled the main oauth request for twitter on the user's login button, and then with the token and twitter secret that I get after they successfully logged in, I fulfill the request for obtaining 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 cognito id and list of datasets for this user.

? .

+4
1

, . , , , .

- , Google, Facebook, Twitter ..

Twitter, .

, .

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

+3

Source: https://habr.com/ru/post/1664959/


All Articles