You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Amazon Cognito重置密码时触发InvalidParameterException异常的问题排查求助

Amazon Cognito重置密码时触发InvalidParameterException异常的问题排查求助

我最近在做Amazon Cognito用户重置密码的功能,写了一段处理重置逻辑的代码,但用Postman调用API时一直触发InvalidParameterException异常,HTTP状态码为400,折腾了好一阵都没找到问题根源,来求助各位大佬!

我的代码实现

async resetPassword(event: ResetPassword) {
  try {
    const { email, newPassword, session } = event;
    const input = {
      ClientId: process.env.CLIENT_ID,
      ChallengeName: ChallengeNameType.NEW_PASSWORD_REQUIRED,
      ChallengeResponses: { USERNAME: email, NEW_PASSWORD: newPassword },
      Session: session,
    };
    const command = new RespondToAuthChallengeCommand(input);
    const response = await this.cognitoClient.send(command);
    return sendResponse(StatusCodes.OK, {
      status: ResponseStatus.SUCCESS,
      message: SuccessMessages.USER_LOGGED_IN,
      data: response,
    });
  } catch (error) {
    throw error;
  }
}

调用API后返回的错误信息

"body": { "name": "InvalidParameterException", "$fault": "client",
"$metadata": { "httpStatusCode": 400, "requestId":
"66a714b4-7a05-4eb5-ae3e-cfeac186fdaa", "attempts": 1,
"totalRetryDelay": 0 }, "__type": "InvalidParameterException" }

我自己初步排查过的点

  • 确认process.env.CLIENT_ID和Cognito用户池的客户端ID完全一致
  • 传递的email格式正确,且是用户池中已存在的用户邮箱
  • session是通过ForgotPassword流程获取的有效会话值

有没有大佬遇到过类似的问题?或者能帮我分析下还有哪些可能的原因导致这个异常?

备注:内容来源于stack exchange,提问作者SKS

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 13:34:51