[英]How to make user attributes from AWS userpool updateable?
我正在嘗試使用 AWS Amplify 更新來自 AWS Cognito 用戶池的用戶的屬性。
try {
const user = await Auth.currentAuthenticatedUser();
await Auth.updateUserAttributes(user, {
'nickname': 'newtestname'
});
} catch (error) {
console.log(error);
}
但我收到以下錯誤:
InvalidParameterException: user.nickname: Attribute cannot be updated.
我希望它是可更新的,因為我在 SAM 模板的 userpool-client 部分設置了可寫屬性:
WriteAttributes:
- email
- nickname
UserPoolId: !Ref MyCognitoUserPool
我沒有應用程序客戶端機密並且啟用了所有身份驗證流。 安全配置設置為啟用。 用戶可以注冊,所以我假設客戶端中的Amplify配置沒問題。
這里有什么問題?
我發現了這個問題。 在創建用戶池時,我必須在模式定義中設置mutable
標志,如下所示:
Schema:
- Name: email
Mutable: true
...
- Name: nickname
Mutable: true
...
https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_CreateUserPool.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.