Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Cognito: Methods to Get a List of users?

I'm developing a web application using Angular 4 (with TypeScript language) front-end side, and using AWS services back-end size. This application can be only accessed by a group of users (each has its own mail and password). This group of users is defined in AWS Cognito - User Pool. How can I have the entire list of these users with their properties to see her in the frontend? And how do I change their properties only frontend side?

I saw the JavaScript methods for AWS Cognito (https://github.com/aws/amazon-cognito-identity-js), but I didn't find anything for what I want to do.

I would like to use some method to show the full list of users with their properties (as seen in the AWS mangement console of Cognito) and that always, thanks to another method, my application it's able to edit some information as a "group" of a user.

Can anyone tell me if this is possible?

like image 515
claudioz Avatar asked Sep 18 '17 13:09

claudioz


People also ask

Can you export users from Cognito?

Amazon Cognito customers often need to export their users to facilitate more complex user queries, or to provide resiliency in case of regional failure or accidental deletion of their users.

How do you query a Cognito user pool?

To search for a user in the Amazon Cognito consoleChoose User Pools. Choose an existing user pool from the list. Choose the Users tab, and then enter in the user's username in the search field. Note that some attribute values are case-sensitive (for example, Username).

Does Cognito store user data?

With Amazon Cognito, you can save user data in datasets that contain key-value pairs. Amazon Cognito associates this data with an identity in your identity pool so that your app can access it across logins and devices.

What is the main difference between Cognito user pool and Cognito identity pool?

With a user pool, your app users can sign in through the user pool or federate through a third-party identity provider (IdP). Identity pools are for authorization (access control). You can use identity pools to create unique identities for users and give them access to other AWS services.


1 Answers

Late response but for those who will probably need it :

  1. Create a new IAM policy, with the Cognito Listusers allowed

  2. the code in JS

    const cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider({
         apiVersion: '2016-04-18',
         region: "eu-central-1",
         credentials: Auth.essentialCredentials(credentials)
       });
       var params = {
         UserPoolId: environment.amplify.Auth.userPoolId, /* required */
         AttributesToGet: [
           "email",
         ],
         Limit: 0
       };
       cognitoidentityserviceprovider.listUsers(params, function (err, data) {
         if (err) console.log(err, err.stack); // an error occurred
         else console.log(data);           // successful response
       });
     });
    
like image 92
sidali Avatar answered Oct 13 '22 01:10

sidali