Reputation: 3923
I added a few custom properties in the User configuration off my AWS Cognito User Pool. I have my app in objective-c similar to the sample project CognitoYourUserPoolsSample. Everything works fine and I can sign-in/sign-up without any problem.
Though, I don't know how to access and set all the User custom attributes that I added in the User Pool config. I can access the default attributes values from the response object AWSCognitoIdentityProviderGetUserResponse for example. They are stored in the _userAttributes property (e.g. phone, email, etc.).
My questions are:
Where are the custom attributes stored?
What is the proper way to set them during sign-up?
I get the following error when I try to sign-up with custom attributes using the same approach as the default attributes:
// add custom attributes
AWSCognitoIdentityUserAttributeType * subscriptionType = [AWSCognitoIdentityUserAttributeType new];
subscriptionType.name = @"subscriptionType";
subscriptionType.value = @"Premium";
[attributes addObject:subscriptionType];
responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response body:
{"__type":"NotAuthorizedException","message":"A client attempted to write unauthorized attribute"}
Thanks!
Upvotes: 1
Views: 2786
Reputation: 1
As I found in the issue: Signup with custom attributes in Cognito user pools to set the value for custom attribute you must set a write permissions for it. Open Amazon Cognito Console -> YourPool -> General Settings -> App Clients -> Show Details -> Set attribute read and write permissions and activate checkboxes for your custom attributes.
Also in code attribute name should contain a prefix 'custom:' i.e. subscriptionType.name = @"custom:subscriptionType"; and those values are shown in AWS console.
Upvotes: 0
Reputation: 226
To answer your questions:
Thanks
Upvotes: 1