【问题标题】:How can I get UserPool details by IdentityPool/UserPool id (sub)如何通过身份池/用户池 ID(子)获取用户池详细信息
【发布时间】:2021-12-31 17:18:57
【问题描述】:
【问题讨论】:
标签:
aws-sdk
amazon-cognito
aws-sdk-js
【解决方案1】:
我想我找到了解决办法,实际上是在表面上。
拥有用户池 ID 1 可以使用 ListUsers 调用和过滤器 sub = \"${userId}\"。要使用的客户端是CognitoIdentityProviderClient,如果使用JS的话。
const client = new CognitoIdentityProviderClient({
region: REGION,
credentials: fromCognitoIdentityPool({
client: new CognitoIdentityClient({ region: REGION }),
logins: {
[PROVIDER_ID]: token
},
identityPoolId: ID_POOL_ID
})
});
const filter = `sub = \"${userPoolId}\"`;
const resp = await client.send(new ListUsersCommand({
UserPoolId: USER_POOL_ID,
Filter: filter,
Limit: 1
}));
当然也可以使用 AdminGetUser,就像上面提到的 Ulas Keles,如果它适用的话