2017-08-03 201 views
0

如何从aws认知中获取所有用户?AWS通过JS获取所有用户的认证信息

我发现这一点:列表的用户 http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#listUsers-property

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

这是一个工作示例:

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); 
     } 
    }); 
相关问题