我们在NodeJS中开发REST API并使用DynamoDB作为数据库,
我假装使用Cognito来处理Auth多个帐户,但是在示例中总是首先获得cognitoID并且稍后使用DynamoDB,它不能发送cognitoID到客户端并使用此id或类似于凭证的东西来访问DynamoDB whitout refind CognitoID ??
FB.login(function (response) {
if (response.authResponse) { // logged in
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'us-east-1:1699ebc0-7900-4099-b910-2df94f52a030',
Logins: {
'graph.facebook.com': response.authResponse.accessToken
}
});
AWS.config.credentials.get(err,data){
console.log('You are now logged in.');
//Here i can use Dynamo without any problem,
//but i allways need save Facebook Token ID and get CognitoID
//for ALL the connections
//there is no way to save CognitoID and use this
//The ID of my users in Dynamo is CognitoID
var db = new AWS.DynamoDB();
db.listTables(function(err, data) {
console.log(data.TableNames);
});
}
} else {
console.log('There was a problem logging you in.');
}
});