Page updated Nov 14, 2023

Set up password change and recovery

Amplify Android v1 is now in Maintenance Mode until May 31st, 2024. This means that we will continue to include updates to ensure compatibility with backend services and security. No new features will be introduced in v1.

Please use the latest version (v2) of Amplify Library for Android to get started.

If you are currently using v1, follow these instructions to upgrade to v2.

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()) );
2 "username",
3 result -> Log.i("AuthQuickstart", result.toString()),
4 error -> Log.e("AuthQuickstart", error.toString())

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

Note that you must call confirmResetPassword in the same app session as you call resetPassword. If you close the app, you'll need to call resetPassword again.

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

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()) );
2 "existingPassword",
3 "newPassword",
4 () -> Log.i("AuthQuickstart", "Updated password successfully"),
5 error -> Log.e("AuthQuickstart", error.toString())