You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to handle email conflicts when updating attributes during federated login (Sync Mode: FORCE)
#43605
I am integrating Keycloak with an external OAuth 2.0 identity provider and have encountered an edge case related to email uniqueness conflicts during manual account linking.
Configuration
Sync Mode: FORCE (user attributes, including email, are updated on every login)
First Broker Login: Manual linking is supported, allowing users to link IdP accounts to existing Keycloak accounts even without matching attributes
Scenario
User has an existing local Keycloak account (userA) with email abc@example.com (not linked to the IdP)
The same person logs in via the identity provider with email abc@example.com
During first broker login flow, the user manually links the IdP account to a different Keycloak account with email xyz@example.com
After linking completes, the sync process attempts to update the email from xyz@example.com to abc@example.com
Exception thrown: Email abc@example.com already exists (duplicate emails not allowed in the realm)
Current Behavior
The federated link is successfully established before the error occurs
User receives a generic error message (Messages.IDENTITY_PROVIDER_UNEXPECTED_ERROR)
User cannot understand what went wrong and likely doesn't remember having an old account with that email
The error is caught and rendered with a generic error page.
Question
What would be the best approach to provide a clearer, more actionable error message to users? Is there a better way to handle this situation gracefully?
Any guidance or best practices on handling this scenario would be greatly appreciated!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I am integrating Keycloak with an external OAuth 2.0 identity provider and have encountered an edge case related to email uniqueness conflicts during manual account linking.
Configuration
FORCE(user attributes, including email, are updated on every login)Scenario
userA) with emailabc@example.com(not linked to the IdP)abc@example.comxyz@example.comxyz@example.comtoabc@example.comabc@example.comalready exists (duplicate emails not allowed in the realm)Current Behavior
Messages.IDENTITY_PROVIDER_UNEXPECTED_ERROR)Technical Details
The exception occurs in the following call chain:
The error is caught and rendered with a generic error page.
Question
What would be the best approach to provide a clearer, more actionable error message to users? Is there a better way to handle this situation gracefully?
Any guidance or best practices on handling this scenario would be greatly appreciated!
All reactions