最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

AWS Cognito添加自定义属性

IT培训 admin 4浏览 0评论

AWS Cognito添加自定义属性

大家好,所以我在这里遇到了困境。我试图向我的AWS Cognito用户添加自定义属性,但是每当出现此错误时,都会出现以下错误:{"message":"Invalid user attributes: custom:expiration_date: Attribute does not exist in the schema.\n","code":"InvalidParameterException","time":"2019-10-08T20:29:26.050Z","requestId":"e088a624-95a3-4d42-a8d2-e2029e41f890","statusCode":400,"retryable":false,"retryDelay":30.119738164581644}但是我在AWS用户池中定义了以下属性,如屏幕快照所示。

我有以下代码来更新属性,但没有成功。

router.put("/set-user-expiration-date", async (req, res) => {
  if (res.locals.user && res.locals.user.role === "admin") {
    try {
      const date = req.body.expirationDate.toString();
      const params = {
        UserAttributes: [{ Name: "custom:expiration_date", Value: date }],
        UserPoolId: process.env.AWS_COGNITO_USER_POOL_ID,
        Username: req.body.username
      };
      await cognito.adminUpdateUserAttributes(params).promise();
      res.send("Successfully updated.");
    } catch (error) {
      res.send(error);
    }
  } else {
    res.status(401).send("No admin rights");
  }
});

这里的任何帮助都会很棒。谢谢:)

回答如下:

问题是字符数限制。我在最大数量上有很多方法,这导致它出错。创建新属性并将最大值设置为256后,它就可以正常工作。

AWS Cognito添加自定义属性

大家好,所以我在这里遇到了困境。我试图向我的AWS Cognito用户添加自定义属性,但是每当出现此错误时,都会出现以下错误:{"message":"Invalid user attributes: custom:expiration_date: Attribute does not exist in the schema.\n","code":"InvalidParameterException","time":"2019-10-08T20:29:26.050Z","requestId":"e088a624-95a3-4d42-a8d2-e2029e41f890","statusCode":400,"retryable":false,"retryDelay":30.119738164581644}但是我在AWS用户池中定义了以下属性,如屏幕快照所示。

我有以下代码来更新属性,但没有成功。

router.put("/set-user-expiration-date", async (req, res) => {
  if (res.locals.user && res.locals.user.role === "admin") {
    try {
      const date = req.body.expirationDate.toString();
      const params = {
        UserAttributes: [{ Name: "custom:expiration_date", Value: date }],
        UserPoolId: process.env.AWS_COGNITO_USER_POOL_ID,
        Username: req.body.username
      };
      await cognito.adminUpdateUserAttributes(params).promise();
      res.send("Successfully updated.");
    } catch (error) {
      res.send(error);
    }
  } else {
    res.status(401).send("No admin rights");
  }
});

这里的任何帮助都会很棒。谢谢:)

回答如下:

问题是字符数限制。我在最大数量上有很多方法,这导致它出错。创建新属性并将最大值设置为256后,它就可以正常工作。

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论