我一直在使用AWS cognito,并尝试更新preferred_username
属性。
我尝试了Auth.updateUserAttributes
通话,但没有成功。
这是整个代码:
Auth.updateUserAttributes(user, {
preferred_username: "new_username",
})
.then((data) => {
setUser(data);
console.log("updateUserAttributes succ", data);
})
.catch((error) => {
console.log("updateUserAttributes err", error);
});
})
.catch((r) => console.log("getUser err", r));
我还检查了 app客户端设置,以获取对preferred_username
属性的读写权限。
仍然出现此错误:
updateUserAttributes err Object {
"code": "NotAuthorizedException",
"message": "Access Token does not have required scopes",
"name": "NotAuthorizedException",
}
我也尝试了其他属性,例如website
,但得到了相同的响应。
谢谢。
似乎来自外部身份提供商的用户无法更新其属性here。
有人可以确认或否认吗?