当我尝试使用Cognito登录经过身份验证的用户时,我收到以下错误。我正在尝试访问DynamoDB。
错误:配置中缺少凭据
“NotAuthorizedException:配置中缺少凭据
AWS.config.update({region:'us-west-2'});
if (cognitoUser != null) { cognitoUser.getSession(function(err, result) {
if (result) {
console.log('You are now logged in.');
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: config.IdentityPoolId,
Logins: {
"cognito-idp.us-west-2.amazonaws.com/us-west-2_XXXXXXX": result.getIdToken().getJwtToken()
}
});
}
});
}
var dynamoDB = new AWS.DynamoDB(AWS.config.credentials)
dynamoDB.listTables(function(err, data) {
if (err) console.log(err, err.stack);
else console.log(data.TableNames);
});
答案 0 :(得分:0)
您需要在label