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

Delete user account

Invoke the deleteUser API to delete a user from the Auth category. This action will also sign your user out.

If your application uses a Cognito User Pool, which is the default configuration for the Amazon Cognito plugin, this action will delete the user from the Cognito User Pool. It will have no effect if you are federating with a Cognito Identity Pool alone.

Depending on your application, data associated with your user may be stored in other resources such as Amazon DynamoDB or AWS S3. It is recommended that you carefully evaluate this data and implement code to remove or otherwise sanitize it, if necessary, prior to giving users the ability to delete their own user record.

Before invoking the “delete user” API, you can first delete associated user data from the GraphQL API. For example, if you are using Amplify CLI's GraphQL transformer to persist user data via owner based access control, you could follow these instructions to delete associated user data.

This allows you to address any guidelines that require your app to delete data associated with a user who deletes their account.

Amplify.Auth.deleteUser(
() -> Log.i("AuthQuickStart", "Delete user succeeded"),
error -> Log.e("AuthQuickStart", "Delete user failed with error " + error.toString())
);
Amplify.Auth.deleteUser(
{ Log.i("AuthQuickStart", "Delete user succeeded") },
{ Log.e("AuthQuickStart", "Delete user failed with error", it) }
)
try {
Amplify.Auth.deleteUser()
Log.i("AuthQuickStart", "Delete user succeeded")
} catch (error: AuthException) {
Log.e("AuthQuickStart", "Delete user failed with error", error)
}
RxAmplify.Auth.deleteUser()
.subscribe(
() -> Log.i("AuthQuickStart", "Delete user succeeded"),
error -> Log.e("AuthQuickStart", "Delete user failed with error " + error.toString())
);