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
相关产品推荐
相关产品推荐

