我试图在AWS中使用API服务来从Cognito中获取所有用户,但出现以下错误:
错误:配置中缺少凭据
我正在使用的服务是cognitoidentityserviceprovider.listUsers
,并且在所有调用中都遇到相同的错误。
我在node.js中的代码:
var aws = require("aws-sdk");
var poolData = {
UserPoolId: 'xxxxxx', // your user pool id here
ClientId: 'xxxxx',
region: 'eu-west-1'
}
var params = {
UserPoolId: 'xxxxxxxx', /* required */
};
aws.config.update({
region: 'eu-west-1',
accessKeyId: 'xxxxxxxxx',
secretAccessKey: "xxxxxxxxxxxxxxxx",
})
var cognitoidentityserviceprovider = new
aws.CognitoIdentityServiceProvider(poolData);
cognitoidentityserviceprovider.config.credentials = new
aws.CognitoIdentityCredentials({
IdentityPoolId: 'xxxxxxxxx'
});
cognitoidentityserviceprovider.listUsers(params, (err, data) => {
if (err) {
console.log(err);
}
else {
console.log("data", data);
}
})