AWS Cognito remove linked accounts from social IdPs

Viewed 21

I have a pre sign-up lambda trigger that links accounts so that account with email and password is always linked with an account created with Google IdP using adminLinkProviderForUser. This creates 2 users in cognito which are connected and have the same id. But now when the user wants to delete his account, I want to delete both of them. I can succesfully remove the account created with email and password like this:

const deleteUserCommand = new AdminDeleteUserCommand({
    UserPoolId: poolId,
    Username: id,
  });
await this.cognito.send(deleteUserCommand);

However, the account created with 3rd party persists and I still can see it in cognito. I also tried to use AdminDisableProviderForUser before removing the account but it didnt help, the account is still there. Any ideas on how can I delete everything related to the user?

0 Answers
Related