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