Aws lambda AWS Cognito使用节点js中的自定义属性注册,导致错误

Aws lambda AWS Cognito使用节点js中的自定义属性注册,导致错误,aws-lambda,amazon-cognito,aws-userpools,Aws Lambda,Amazon Cognito,Aws Userpools,我正试图通过一个lambda函数和AWS用户池构建注册,我在其中添加了一个名为type的自定义属性。 当我通过注册发送类型值时,出现一个错误“客户端试图写入未经授权的属性”” 我正在使用“amazon cognito identity js”包来保存数据。 这是我的代码片段 const attributeList = []; attributeList.push(new AmazonCognitoIdentity.CognitoUserAttribute({Na

我正试图通过一个lambda函数和AWS用户池构建注册,我在其中添加了一个名为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**

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

步骤:

  • 转到您的Cognito用户池页面
  • 单击左侧菜单中的“应用程序客户端”
  • 单击“设置属性读写权限”
  • 确保为所需属性添加了必要的(读/写)权限

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

    步骤:

  • 转到您的Cognito用户池页面
  • 单击左侧菜单中的“应用程序客户端”
  • 单击“设置属性读写权限”
  • 确保为所需属性添加了必要的(读/写)权限

  • 除了上述答案之外,有时客户机下的自定义属性可能需要时间才能反映出来。因为我在15分钟左右就注意到了,但1小时后它就出现了。

    除了上面的答案之外,有时自定义属性可能需要时间来反映在客户端下。因为我在15分钟左右就注意到了,但1小时后它就出现了。

    此外,如果这些是受保护的属性(意味着您不希望用户有权更改它们),您可能不想授予写入权限,而只想在服务器端更新它们。感谢您的帮助,@cyberenternetal(意味着您不希望用户有权更改它们),您可能不想授予写入权限,而只想在服务器端更新它们。感谢您的帮助,@CyberEternal。