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

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

问题描述

我有配置了Cognito用户池作为身份验证提供程序的AWS Cognito身份池。

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

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

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.

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

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

推荐答案

与Cognito联合交换的ID令牌用于获取身份ID和凭据的身份服务已经具有所有用户属性。您不需要对任何服务进行额外调用。

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.

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

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.

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

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

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

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