如何使用认知身份 ID 获取用户属性(用户名、电子邮件等) [英] How to get user attributes (username, email, etc.) using cognito identity id

查看:38
本文介绍了如何使用认知身份 ID 获取用户属性(用户名、电子邮件等)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 AWS Cognito 身份池,配置了 Cognito 用户池作为身份验证提供商.

假设我在 Cognito 身份池中有一个身份的身份 ID(例如 us-east-1:XXaXcXXa-XXXX-XXXX-XXX-XXXXXXXXXXXX),其中该身份与 Cognito 用户池中的用户有链接登录.

使用身份 ID,我如何获取链接的用户详细信息(电子邮件、电话、用户名)?

解决方案

您与 Cognito 联合身份服务交换以获取身份 ID 和凭据的 ID Token 已经具有所有用户属性.您无需额外拨打任何服务电话.

它是一个 JWT 令牌,您可以使用客户端上的任何库来解码这些值.您可以阅读 本指南 了解有关 Cognito 用户池出售的令牌的更多信息.

或者,您也可以使用访问令牌调用 GetUser API 将返回所有用户信息.

I have AWS Cognito Identity Pool that is configured with Cognito User Pool as an authentication provider.

Assume I have identity ID of an identity in Cognito Identity Pool (e.g. us-east-1:XXaXcXXa-XXXX-XXXX-XXX-XXXXXXXXXXXX) where this identity has a linked login to a user in Cognito User Pool.

Using identity ID, how can I get the linked user details (email, phone, username)?

解决方案

The ID Token that you exchange with Cognito federated identity service to get the identity id and credentials already has all user attributes. You do not need an extra call to any service.

It is a JWT token and you can use any library on the client to decode the values. You can read this guide for more information about the tokens vended by Cognito user pools.

Alternatively, you can also use the Access Token to call GetUser API which will return all the user information.

这篇关于如何使用认知身份 ID 获取用户属性(用户名、电子邮件等)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆