Skip to content

Cognito ForgotPassword API returns "InvalidParameterException: Cannot reset password for the user as there is no registered/verified email or phone_number" despite user having verified attributes #7101

@eaglex12

Description

@eaglex12

Checkboxes for prior research

Describe the bug

I'm facing an issue with ForgotPasswordCommand. I'm passing the username, and both email and phone are verified — OTP login works fine. But Cognito still throws InvalidParameterException saying no verified email/phone exists. Could it be that I need to pass the actual Cognito username instead of the email? Any idea how to fix this?

This is error : error: InvalidParameterException: Cannot reset password for the user as there is no registered/verified email or phone_number

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/package-name@version, ...

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

20.14.0

Reproduction Steps

User logs in using their email as username (email and phone are verified in Cognito).

OTP-based MFA works correctly for the user.

When calling ForgotPasswordCommand with the same username (email), Cognito returns:
InvalidParameterException: Cannot reset password for the user as there is no registered/verified email or phone_number.

Verified via admin-get-user that the user’s actual Cognito username is different (e.g., "michael.smith").

Suspected cause: ForgotPasswordCommand requires the internal Cognito username, not the email alias

Observed Behavior

When calling ForgotPasswordCommand with the user’s email as the username, the request fails with an InvalidParameterException stating there is no registered or verified email or phone number, despite both being verified and MFA via OTP working fine. Logs confirm this error with a 400 status. Using admin-get-user, the actual Cognito username differs from the email, indicating that ForgotPasswordCommand requires the internal username rather than the email alias.

Expected Behavior

When calling ForgotPasswordCommand with the correct username (email or internal username), the request should succeed and return a response containing CodeDeliveryDetails with information about where and how the verification code was sent, for example:
{
"CodeDeliveryDetails": {
"Destination": "user's email or phone",
"DeliveryMedium": "EMAIL" or "SMS",
"AttributeName": "email" or "phone_number"
}
}

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.closed-for-stalenessp3This is a minor priority issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions