I'm trying to update the value of the standard attribute email of a user in a AWS Cognito user pool, but I'm getting this error:
Amazon.CognitoIdentityProvider.Model.InvalidParameterException: user.email: Attribute cannot be updated
The code I'm using is:
AdminUpdateUserAttributesRequest adminUpdateUserAttributesRequest = new()
{
UserPoolId = CognitoUserPoolId,
Username = userDetailMessage.CognitoUsername
};
var emailAttribute = new AttributeType
{
Name = "email",
Value = userDetailMessage.Email
};
adminUpdateUserAttributesRequest.UserAttributes.Add(emailAttribute);
var _ = _client.AdminUpdateUserAttributesAsync(adminUpdateUserAttributesRequest).Result;
The same code is working as expected uptading, for example, a custom attribute, but I cannot use it for updating email attribute.
CodePudding user response:
When you created UserPool you defined schema https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cognito-userpool-schemaattribute.html
For example:
Schema:
- Name: 'email'
AttributeDataType: 'String'
DeveloperOnlyAttribute: False
Mutable: True
Required: True
Mutable attribute is answer to your question