AWS Cognito- get user information with ID

Is there any way to get information about the user in AWS Cognito pool (on android) who is not logged in, knowing his ID? I tried that code:

 AppHelper.getPool().getUser(username).getDetailsInBackground(detailsHandler);

However it works only for username who is currently logged in.

Upvotes: 3

Views: 4043

Answers (2)

Jimmy Obonyo Abor
Jimmy Obonyo Abor

Reputation: 7885

Use ListUsers() Api , with filters ie

    client = boto3.client('cognito-idp', region_name=USER_POOL_REGION)
    user = client.list_users(
            UserPoolId = USER_POOL_ID,
            AttributesToGet=attributes, # ie ['email', 'sub',]
            Filter='sub = "<user-id-here>"',
            #Limit=limit
    )
    

for complex filters and examples see https://docs.aws.amazon.com/cognito/latest/developerguide/how-to-manage-user-accounts.html#cognito-user-pools-searching-for-users-listusers-api-examples

Upvotes: 0

Chetan Mehta
Chetan Mehta

Reputation: 5671

No, there is not.

You get get user information given the user name by calling AdminGetUser from you backend with your developer credentials but not from an Android client.

Upvotes: 4

Related Questions