简体   繁体   English

AWS Cognito GetUser API未返回所有属性

[英]AWS Cognito GetUser API not returning all attributes

Currently I am working on an application that makes use of AWS Cognito. 目前我正在开发一个使用AWS Cognito的应用程序。 I am storing a number of custom attributes on each user, and pulling from that information when users sign in or when they update their information. 我在每个用户上存储了许多自定义属性,并在用户登录或更新信息时从该信息中提取。 For the most part this works with no problems. 在大多数情况下,这没有问题。 However, some of my custom attributes are not being returned by the getUser function. 但是,getUser函数没有返回我的一些自定义属性。 Confused by this, I double checked the users in the aws cognito console and found that all of the attributes were present, despite not being returned. 对此感到困惑,我在aws cognito控制台中仔细检查了用户,发现尽管没有返回,但所有属性都存在。 Finally, I triple checked by looking at what was being returned when I listed all the users in the pool and displayed the attribute I was looking for. 最后,当我列出池中的所有用户并显示我正在寻找的属性时,通过查看返回的内容进行三重检查。 In that case, the attribute was appearing with no difficulty. 在这种情况下,属性出现没有任何困难。 This is a very bizarre issue because it is failing silently, only giving me some of the information tied to a user instead of all of it. 这是一个非常奇怪的问题,因为它无声地失败,只给了我一些与用户相关的信息,而不是全部。 Even more bizarre is the fact that it is even giving me some of the custom attributes, just not all of them. 更奇怪的是它甚至给了我一些自定义属性,而不是全部。 Does anyone have any idea what the problem could be or what else to test? 有谁知道问题可能是什么或测试什么?

For reference, I am accessing this information using a node.js server. 作为参考,我使用node.js服务器访问此信息。 I am using this: http://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetUser.html to get a specific user using an access token. 我使用这个: http//docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetUser.html来获取使用访问令牌的特定用户。 I am also using this http://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListUsers.html for testing purposes to see if the attributes are present at all. 我也使用此http://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListUsers.html进行测试,以查看属性是否存在。

After a substantial amount of digging I have finally discovered the solution. 经过大量的挖掘后,我终于找到了解决方案。 The GetUser API will only return attributes marked as readable (I didn't even know you could edit the read/write permission for attributes). GetUser API仅返回标记为可读的属性(我甚至不知道您可以编辑属性的读/写权限)。

To access this, go to the page for your user pool, then navigate to: 要访问它,请转到用户池的页面,然后导航到:

General settings > App clients > Show Details > Set attribute read and write permissions 常规设置>应用程序客户端>显示详细信息>设置属性读取和写入权限

.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM