Opening the door to social login with identity brokering: getting to know providers such as Google, GitHub, and Facebook, creating an OAuth app and configuring redirect URIs, mapping scopes and attributes, managing first broker login and account linking, up to adding custom identity providers.

In episode 15 you connected Keycloak to external directories such as LDAP and Active Directory. Episode 16 adds a different entrance: social login through identity brokering. You'll let users sign in with Google, GitHub, Facebook, and other accounts — while Keycloak remains the center that holds the session, links external accounts to internal identities, and enriches the user profile from provider claims.
Identity brokering is a pattern where Keycloak plays the intermediary: it doesn't hold user credentials, but receives identity from an external provider (the broker) and forwards it to the application. Unlike user federation, which reads directly from a directory, here authentication happens at the provider's side, then the result is handed to Keycloak.
Technically, each external provider is an identity provider registered in the realm via the Identity Providers tab in the admin console. Keycloak becomes a brokered IdP for its applications: applications still talk to Keycloak (OIDC or SAML), never knowing the user actually logged in at Google.
| Provider | Protocol | What to prepare | Redirect URI in Keycloak |
|---|---|---|---|
| OIDC | OAuth client in Google Cloud Console | https://keycloak.example.com/realms/demo/broker/google/endpoint | |
| GitHub | OAuth 2.0 | OAuth App on GitHub | https://keycloak.example.com/realms/demo/broker/github/endpoint |
| OAuth 2.0 | App in Facebook for Developers | https://keycloak.example.com/realms/demo/broker/facebook/endpoint | |
| Microsoft | OIDC | App registration in Azure | https://keycloak.example.com/realms/demo/broker/microsoft/endpoint |
| OAuth 2.0 | App in LinkedIn Developer Portal | https://keycloak.example.com/realms/demo/broker/linkedin/endpoint | |
| OAuth 2.0 | App in Twitter Developer | https://keycloak.example.com/realms/demo/broker/twitter/endpoint |
Redirect URI in the last column is the address you must register in each provider's developer portal. Without registering it, the provider will reject the callback with a redirect_uri_mismatch error.
The steps always begin at the provider's developer portal:
1. Open the provider's developer portal (Google Cloud, GitHub, etc.)
2. Create a new application or OAuth client
3. Note the client ID and client secret you receive
4. Register the Keycloak redirect URI for that broker
5. Choose the scopes to request (email, profile)
6. Save and note the credentialsExample list of redirect URIs registered in the developer portal:
https://keycloak.example.com/realms/demo/broker/google/endpoint
https://keycloak.example.com/realms/demo/broker/github/endpoint
https://keycloak.example.com/realms/demo/broker/facebook/endpointclient_id and client_secret are then entered into Keycloak on the Identity Providers tab for the relevant provider.
Scopes determine what data is requested from the provider — the most basic are email and profile. In Keycloak, the received claims can be mapped to user profile attributes through mappers. For example, the email claim from Google becomes the Keycloak user's email value, and the name from profile is used to fill in the first and last names.
The rule of thumb: request as few scopes as possible. Every piece of data not requested won't be received, and every piece received is your responsibility to protect.
When a user first logs in through an external provider, Keycloak runs the first broker login flow — a special flow for linking the external identity to an internal account:
Account linking is the process of merging an external identity with a Keycloak account. There are two approaches:
For security, the manual mechanism is stronger: without it, anyone controlling a Google account with another user's email address could hijack that account.
Claims from the provider aren't only used to sign in — they can also enrich the user profile. Mappers fill attributes such as location, language, or avatar from provider data. But also pay attention to trust levels: data claimed by the provider isn't always verified. A email_verified claim from the provider must be treated differently from an email verified by Keycloak itself.
Important
Automatic email-based account linking is convenient, but prone to account takeover when the provider doesn't verify email address ownership. For applications handling sensitive data, use the manual flow that asks for local account login confirmation before linking.
Besides social providers, Keycloak supports custom identity providers:
This lets Keycloak become a federation hub: applications talk to a single Keycloak, while behind it Keycloak talks to Google, GitHub, corporate IdPs, and LDAP all at once.
Every identity provider uses an alias that becomes part of the broker redirect URI, for example google, github, or corporate. This alias is also the identity Keycloak uses to link accounts: when a user is connected to more than one provider, Keycloak records each combination of alias and external identity.
For security, there are several habits to maintain:
client_secret in a safe place — it's the credential linking Keycloak to the provider, equivalent to a password.client_id and client_secret entered into Keycloak should be taken directly from the developer portal, not copied through email or messages that could be intercepted.
In this episode 16, you opened social login through identity brokering: the broker concept and the Identity Providers tab; Google, GitHub, Facebook, Microsoft, LinkedIn, and Twitter providers; creating an OAuth app with client ID, client secret, and redirect URIs; mapping scopes and attributes; the first broker login flow, account linking, and profile enrichment; plus custom OIDC and SAML identity providers.
Key takeaways:
In the next episode (episode 17), we complete identity management from the provisioning side: SCIM — the REST protocol for creating, updating, and deleting users across systems automatically.