cancel
Showing results for 
Search instead for 
Did you mean: 

How to recover forgot password using Magento2 APIs?

How to recover forgot password using Magento2 APIs?

We are creating a Mobile APP I want to recover the forget password of a customer but in the case of magento2 calling API /V1/customers/password got a reset password email after that we can call the below API to reset password

rest/V1/customers/resetPassword

The API have post params

 

{
  "email": "meetanshi.tester@gmail.com",
  **"resetToken": " how to get this "**,
  "newPassword":"test@123"
}

How Can I get the reseToken because in email I couldn't find it.

I also follow the given solutions but cant resolve the problem Thanks

1 REPLY 1

Re: How to recover forgot password using Magento2 APIs?

To recover a forgot password using Magento2 APIs, you need to follow these steps:

  1. Call the /V1/customers/password API with the customer's email address as a parameter. This will trigger Magento to send a password reset email to the customer's email address.

  2. Once the customer receives the email, they will click on the reset password link, which will redirect them to a page where they can enter a new password.

  3. After the customer enters the new password, Magento will generate a reset token and send it to the customer's email address.

  4. The customer will then need to copy the reset token and use it in conjunction with their email address and the new password to call the /V1/customers/resetPassword API.

In your case, as a developer, you can ask the customer to provide you with the reset token, or you can retrieve it by using the Magento2 database.

To retrieve the reset token from the Magento2 database, you can follow these steps:

  1. Log in to your Magento2 database using your favorite database client or command-line tool.

  2. Run the following SQL query, replacing customer_email@example.com with the email address of the customer whose reset token you want to retrieve:

    sqlCopy code
    SELECT * FROM `password_reset_request_event` WHERE `email` = 'customer_email@example.com';
  3. The query will return a row containing the reset token and other information related to the password reset request.

  4. You can then use the reset token to call the /V1/customers/resetPassword API to set a new password for the customer.

Note: Retrieving data directly from the database is not recommended unless you have a good reason to do so. It's always best to use Magento2 APIs whenever possible.