我们在 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.');
}
});