Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated Apr 29, 2024

Set up password change and recovery

Amplify Android v1 is deprecated as of June 1st, 2024. No new features or bug fixes will be added. Dependencies may become outdated and potentially introduce compatibility issues.

Please use the latest version (v2) of Amplify Library for Android to get started. Refer to the upgrade guide for instructions on upgrading your application to the latest version.

Amplify libraries should be used for all new cloud connected applications. If you are currently using the AWS Mobile SDK for Android, you can access the documentation here.

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())
);
Amplify.Auth.resetPassword("username",
{ Log.i("AuthQuickstart", "Password reset OK: $it") },
{ Log.e("AuthQuickstart", "Password reset failed", error) }
)
try {
val result = Amplify.Auth.resetPassword("username")
Log.i("AuthQuickstart", "Password reset OK: $result")
} catch (error: AuthException) {
Log.e("AuthQuickstart", "Password reset failed", error)
}
RxAmplify.Auth.resetPassword("username")
.subscribe(
result -> Log.i("AuthQuickstart", result.toString()),
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())
);
Amplify.Auth.confirmResetPassword("NewPassword123", "confirmation code",
{ Log.i("AuthQuickstart", "New password confirmed") },
{ Log.e("AuthQuickstart", "Failed to confirm password reset", it) }
)
try {
Amplify.Auth.confirmResetPassword("NewPassword123", "code you received")
Log.i("AuthQuickstart", "New password confirmed")
} catch (error: AuthException) {
Log.e("AuthQuickstart", "Failed to confirm password reset", error)
}
RxAmplify.Auth.confirmResetPassword("NewPassword123", "confirmation code")
.subscribe(
() -> Log.i("AuthQuickstart", "New password confirmed"),
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())
);
Amplify.Auth.updatePassword("existingPassword", "newPassword",
{ Log.i("AuthQuickstart", "Updated password successfully") },
{ Log.e("AuthQuickstart", "Password update failed", it) }
)
try {
Amplify.Auth.updatePassword("existingPassword", "newPassword")
Log.i("AuthQuickstart", "Updated password successfully")
} catch (error: AuthException) {
Log.e("AuthQuickstart", "Password update failed", error)
}
RxAmplify.Auth.updatePassword("existingPassword", "newPassword")
.subscribe(
() -> Log.i("AuthQuickstart", "Updated password successfully"),
error -> Log.e("AuthQuickstart", error.toString())
);