Adding Cognito custom attributes post pool creation?

扶醉桌前 提交于 2019-12-24 02:33:45

问题


Is it possible to add Cognito additional custom or standard user attributes post pool creation and once the pool is being used?

In other words is the Schema for the pool totally locked or can we add more custom attributes to it?


回答1:


On AWS Cognito, you have two types of attributes:

  • Standard Attributes: These attributes were selected when the pool was created and cannot be changed.

  • Custom Attributes: These attributes can be added. Once they are added, they cannot be removed or changed




回答2:


@ThomasVdBerge is somewhat correct but the answer needs to be more complete and helpful. At this time custom attributes are poorly setup by AWS. For example, you can't find the field you entered in the Console included in user objects returned by various JS SDK api's unless you have a value in it. To do that you have to enter the value with the CLI, which is unworkable for real apps that are meant for users to enter data with a GUI.

The adminCreateUser api doc states this: "For custom attributes, you must prepend the custom: prefix to the attribute name." However, this crashes JavaScript unless you stringify it as below in my edit.

EDIT:

I've added my code for creating a user form. With this setup I can add user ID's and this field will show in the returned object in the console and in the Cognito database of users.

What I've said above is still correct if you want to add data to a custom field and want to do something with it. Adding users with an interface this way works.

const createUserParams = {
    ...
    UserAttributes: [
       {
       Name: 'custom:user_id',
       Value: enteredData.user_id
       },


来源:https://stackoverflow.com/questions/50087087/adding-cognito-custom-attributes-post-pool-creation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!