How do I look up a cognito user by their sub/UUID?

后端 未结 4 1502
终归单人心
终归单人心 2020-12-16 13:05

I want to look up a user in my Cognito user pool by their sub, which as far as I can tell, is just their UUID. I would like to do this in Java within a Lambda function but c

4条回答
  •  执念已碎
    2020-12-16 13:31

    Old question, but you the username parameter is overloaded in Cognito's adminGetUser method. It is, unfortunately, not documented: adminGetUser SDK

    Here's a snippet:

    const params = {
      UserPoolId: 'someUserPoolId'
      Username: 'random-string-sub-uuid',
    };
    
    CognitoService.adminGetUser(params,(err, data) => {
      console.log(data);
    })
    
    Returns:
    { Username: 'random-string-sub-uuid',
      UserAttributes:
       [ { Name: 'sub', Value: 'random-string-sub-uuid' },
         { Name: 'custom:attributeName', Value: 'someValue' },
         { Name: 'email_verified', Value: 'false' },
         { Name: 'name', Value: 'nameValue' },
         { Name: 'email', Value: 'user@stackoverflow.com' } ],
      UserCreateDate: 2018-10-12T14:04:04.357Z,
      UserLastModifiedDate: 2018-10-12T14:05:03.843Z,
      Enabled: true,
      UserStatus: 'CONFIRMED' }
    

提交回复
热议问题