Page updated Nov 14, 2023

Set up password change and recovery

Reset password

In order to reset your password, use the resetPassword api - this will send a code to the user attribute configured to receive such a reset code (e.g. email or SMS):

Amplify.Auth.resetPassword( "username", result -> Log.i("AuthQuickstart", result.toString()), error -> Log.e("AuthQuickstart", error.toString()) );
1Amplify.Auth.resetPassword(
2 "username",
3 result -> Log.i("AuthQuickstart", result.toString()),
4 error -> Log.e("AuthQuickstart", error.toString())
5);

To complete the password reset process, invoke the confirmResetPassword api with the code you were sent and the new password you want.

Amplify.Auth.confirmResetPassword( "Username", "NewPassword123", "confirmation code you received", () -> Log.i("AuthQuickstart", "New password confirmed"), error -> Log.e("AuthQuickstart", error.toString()) );
1Amplify.Auth.confirmResetPassword(
2 "Username",
3 "NewPassword123",
4 "confirmation code you received",
5 () -> Log.i("AuthQuickstart", "New password confirmed"),
6 error -> Log.e("AuthQuickstart", error.toString())
7);

Change password

A signed in user can update their password using the updatePassword api:

Amplify.Auth.updatePassword( "existingPassword", "newPassword", () -> Log.i("AuthQuickstart", "Updated password successfully"), error -> Log.e("AuthQuickstart", error.toString()) );
1Amplify.Auth.updatePassword(
2 "existingPassword",
3 "newPassword",
4 () -> Log.i("AuthQuickstart", "Updated password successfully"),
5 error -> Log.e("AuthQuickstart", error.toString())
6);