如何从aws cognito中获取所有用户?
var cognito = new AWSCognito.CognitoIdentityServiceProvider;
cognito.listUsers(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
但是当我这样做时,我得到了这个错误:
没有任何定义......
也尝试了这个:
AWS.config.region = 'eu-central-1'; // Region
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'eu-central-1:',
Logins: {
'cognito-idp.eu-central-1.amazonaws.com/eu-central-1_': result.getIdToken().getJwtToken()
}
});
这里我的结果没有定义......
如何获取所有用户?
答案 0 :(得分:0)
这是一个有效的例子:
let params = {
UserPoolId: '<<PoolID>>',
AttributesToGet: [
'email',
'family_name',
'given_name',
'custom:client',
'phone_number'
],
Limit: 0,
};
this.awsSDKAuth().listUsers(params, (err, data) => {
if (err) console.log(err, err.stack); // an error occurred
else {
console.log(data.Users);
}
});