'Auto merge authenticated user from IDP with the existing user in the keycloak

I am working on a authentication/authorization flow with keycloak. I have manually registered some users inside keycloak.

Now, I am using Azure AD as an IDP. When I am trying to login with Azure AD for some email address(email already exists in the keycloak), then I am getting error "User with email <EMAIL> already exists. How do you want to continue?"

Error Screen

My Requirement is to automatically merge my idp authenticated user with the existing keycloack user (same email) by skipping the above screen.

Is there a way to achieve this?

I don't want redundant users in the keycloak for the same email address.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source