I am trying to update attributes from users from a AWS Cognito userpool with AWS Amplify.
try {
const user = await Auth.currentAuthenticatedUser();
await Auth.updateUserAttributes(user, {
'nickname': 'newtestname'
});
} catch (error) {
console.log(error);
}
But I get the following error:
InvalidParameterException: user.nickname: Attribute cannot be updated.
I would expect it to be updateable because I made the attributes writable in the userpool-client section in my SAM template:
WriteAttributes:
- email
- nickname
UserPoolId: !Ref MyCognitoUserPool
This is also reflected correctly in the console:
I have no app client secret and all auth flows enabled. The security configuration is set to enabled. Users can register, so I assume that the Amplify config in the client is alright.
What is wrong here?
I found the issue. On creation of the userpool I had to set the mutable
flag within the schema definition, like so:
Schema:
- Name: email
Mutable: true
...
- Name: nickname
Mutable: true
...
https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_CreateUserPool.html