Im using an external IdP to obtain users JWT tokens using the token-exchange protocol. When the user is not created in the admin console i get no problem and everything works fine, but if when i call the /token endpoint to obtain the access token and the user is already created in the console i get the error “User already created”.
In the DEBUG logs i can see this error error=federated_identity_account_exists, that seems to be part of the DefaultTokenExchange.java class.
Is there a way to avoid this error and merge accounts when calling the endpoint?
Also i noticed that if I create the Identity Provider Link manually, in the user settings it solves the problem.
Thanks in advance
I have experienced the same problem but I have kind of solved it, this was my scenario:
I have kind of solved this situation by trying to use the keycloak login portal, let me explain. I was reading this online discussion: https://keycloak.discourse.group/t/link-idp-to-existing-user/1094/7 and discovered that you can actually see and modify the details and steps of the login flow. Reading the login flow of the google identity provider. The scenario is this, maybe it can help you:
Unfortunately, from the api this error is not manageable and I think it would be very complicated to solve. Maybe if you implement the code with the keycloak api to link the accounts it could work, but I don't think it's worth it, so I will be moving to using the keycloak login portal which works better and requires less effort.