gpt4 book ai didi

aws-lambda - AWS Cognito SignUP 在节点 js 中使用自定义属性导致错误

转载 作者:行者123 更新时间:2023-12-04 16:38:10 25 4
gpt4 key购买 nike

我正在尝试通过 AWS 用户池的 lambda 函数构建 Signup,其中我添加了一个名为 type 的自定义属性。当我通过注册发送类型值时,会出现错误“客户端试图写入未经授权的属性”。

我正在使用“amazon-cognito-identity-js”包来保存数据。这是我的代码片段


const attributeList = [];
attributeList.push(new AmazonCognitoIdentity.CognitoUserAttribute({Name:"name",Value:user.username}));
attributeList.push(new AmazonCognitoIdentity.CognitoUserAttribute({Name:"custom:type",Value:'asd'}));
attributeList.push(new AmazonCognitoIdentity.CognitoUserAttribute({Name:"gender",Value:user.gender}));
attributeList.push(new AmazonCognitoIdentity.CognitoUserAttribute({Name:"email",Value:user.email}));

userPool.signUp(user.email, user.password, attributeList, null, function(err, result){
if (err) {
return reject(err);
}
return resolve(result);
});**strong text**

最佳答案

添加新属性后,您应该选择此应用程序客户端可以读取和写入的用户属性。

步骤:

  1. 前往您的 Cognito 用户池页面
  2. 点击左侧菜单中的“应用程序客户端”
  3. 点击“设置属性读写权限”
  4. 确保您为所需属性添加了必要的(读/写)权限

enter image description here enter image description here

关于aws-lambda - AWS Cognito SignUP 在节点 js 中使用自定义属性导致错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66402119/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com