AWS Cognito:具有定制属性的“ NotAuthorizedException,客户端尝试写入未经授权的属性”

问题描述

我正在尝试通过AuthClass上的updateUserAttributes方法来更新自定义(甚至是认)属性,但是我遇到了NotAuthorizedException错误

添加了两个自定义属性planstripe_id 之后 我创建了用户池,如果有什么不同的话

编辑:我已经使用全新的用户池和应用客户端对其进行了测试,但这仍然是一个问题。

我可以很好地注册登录新用户,但是在尝试更新属性时会出现问题。

我进入了Cognito控制台,以设置自定义属性的写入/读取权限。

enter image description here

这就是我在代码中正在做的事情。

要导入AuthClass的导入语句:

import { Auth } from "aws-amplify";

通过此方法调用用户

this.user = await Auth.currentAuthenticatedUser();

enter image description here

在此函数调用updateAttribute:

 async addAttribute() {

      const attributes = new CognitoUserAttribute({
        Name: "custom:plan",Value: "test",});
      console.log(this.user);
      console.log(attributes);
      
      const update = Auth.updateUserAttributes(this.user,attributes).then( data=> {
        console.log(data);
      });
      
    },

我尝试使用'custom'前缀(不带),并且尝试更改属性(地址),但所有操作都因同一错误而发生。

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)