Skip to content

Keycloak identity provider redirect URIs

Get the redirect URI to register with Google, GitHub, Microsoft and other identity providers when you add them to a Keycloak realm.

Runs in your browser. Nothing you paste is sent to us.

Provider

The public address, the same as your hostname setting. A made-up one is filled in.

Keycloak’s default for this provider is filled in. Use the alias you gave it, if you changed it.

Register this

Redirect URI
https://auth.example.com/realms/acme/broker/google/endpoint
Where it goes
Google Cloud console, the OAuth client’s Authorized redirect URIs
The URI must match exactly, scheme and path included. If sign-in fails with a redirect URI error at the provider, compare it with the address Keycloak sent, which follows your hostname setting.

How to use it

  1. Enter your Keycloak address and realm.
  2. Pick the identity provider.
  3. Check the alias matches the one you use in Keycloak.
  4. Paste the redirect URI into the provider’s app settings.

What to know

When a user signs in with an outside provider, the provider sends them back to Keycloak at /realms/<realm>/broker/<alias>/endpoint. The provider only accepts that address if you registered it.

The alias is the name of the identity provider in the realm. Keycloak suggests the provider’s id, such as google or github, and you can change it when you add the provider.

The address follows Keycloak’s hostname setting, so register the public address, not an internal one.

What identity brokering is

Keycloak can let users sign in with an account they already have elsewhere: Google, GitHub, Microsoft, another OpenID Connect provider, or a company’s SAML identity provider. Keycloak calls this identity brokering, and each outside provider is an identity provider in the realm.

During that sign-in, Keycloak acts as a client of the outside provider. It sends the user to the provider, and the provider sends them back to Keycloak with a code or an assertion. The address the user comes back to is the redirect URI, and the provider accepts it only if you registered it in advance.

A wrong or missing redirect URI is the most common reason a new "Sign in with" button fails. The provider shows an error page and the user never reaches Keycloak again.

How Keycloak 26 builds the redirect URI

Every identity provider in a realm has an alias. The alias is part of the URL Keycloak uses to receive the response.

Broker endpoint
https://<host>/realms/<realm>/broker/<alias>/endpoint

For a SAML identity provider, the same address is the Assertion Consumer Service URL. Keycloak also publishes service provider metadata for it at the same address with /descriptor added, which you can give to the identity provider instead of typing values by hand.

The host part comes from Keycloak’s hostname setting. If that is wrong, Keycloak sends a different redirect URI from the one you registered, and the provider refuses it.

The alias

When you add a provider, Keycloak suggests an alias equal to the provider’s id, such as google, github or microsoft. You can change it when you create the provider, and you will need different aliases if you add the same kind of provider twice, for example two Microsoft tenants. Treat the alias as permanent: it is part of the redirect URI and of the links between users and the provider, so choose it before you register anything.

What happens during a brokered sign-in

Knowing the order of steps makes errors easier to place. A sign-in through an outside provider runs like this.

  1. Your app sends the user to Keycloak’s authorization endpoint, as for any sign-in.
  2. The user picks the provider on Keycloak’s sign-in page, or the app skips that page with the kc_idp_hint parameter.
  3. Keycloak sends the user to the provider with its own client id and the broker redirect URI.
  4. The user signs in at the provider, which sends them back to the broker endpoint with a code or a SAML response.
  5. Keycloak checks the response, finds or creates the matching user through the first broker login flow, and finishes the sign-in.
  6. Keycloak sends the user back to your app with its own authorization code, and the app gets Keycloak tokens.

Your app never talks to the outside provider. It only ever sees Keycloak’s tokens, so you can add or swap providers without changing the app.

Where each provider wants the URI

Every provider has its own console and its own name for the field. These are the ones built into Keycloak with their default aliases.

ProviderDefault aliasWhere to paste the URI
GooglegoogleGoogle Cloud console, OAuth client, Authorized redirect URIs
GitHubgithubGitHub OAuth app, Authorization callback URL
MicrosoftmicrosoftMicrosoft Entra app registration, Redirect URI on the Web platform
GitLabgitlabGitLab application, Redirect URI
FacebookfacebookMeta for Developers, Facebook Login, Valid OAuth Redirect URIs
LinkedInlinkedin-openid-connectLinkedIn Developers app, Authorized redirect URLs
BitbucketbitbucketBitbucket OAuth consumer, Callback URL
OpenID Connect v1.0oidcThe provider’s client settings
Keycloak OpenID Connectkeycloak-oidcThe other Keycloak’s client, Valid redirect URIs
SAML v2.0samlThe identity provider, as the Assertion Consumer Service URL

Provider consoles change their layout from time to time. If a field has moved, look for "redirect", "callback" or "reply URL".

What this tool does

You enter your Keycloak address and realm, pick a provider, and confirm the alias. The tool writes the exact redirect URI to register, and says where it goes in that provider’s settings.

For SAML providers it also gives the metadata URL and Keycloak’s usual service provider entity ID, which is the realm URL. Check that value in the provider’s settings in Keycloak, since it can be changed.

What it does not do

It does not create the identity provider in Keycloak or the app at the provider. It does not know your real alias if you changed it, so it shows the default and lets you edit it. Keycloak itself shows the same redirect URI on the provider’s page once you add it; when in doubt, copy it from there.

How to use it

  1. Enter your Keycloak’s public address, the same value as the hostname option.
  2. Enter the realm the users will sign in to.
  3. Pick the provider and check the alias matches the one you use, or will use, in Keycloak.
  4. Copy the redirect URI and paste it into the provider’s app settings.
  5. Create the identity provider in Keycloak with the same alias, and fill in the client id and secret from the provider.
  6. Test the sign-in in a private browser window.

Where it helps

Adding social sign-in to a new app

Teams often set up Google or GitHub sign-in first. Registering the right URI the first time saves a round of errors and support questions.

Connecting a company’s identity provider

For business customers, Keycloak often brokers to the customer’s own Microsoft Entra ID, Okta or another SAML or OIDC provider. Their administrators ask for the redirect URI or metadata URL; send them the exact values from Keycloak.

Moving to a new host or environment

The redirect URI contains the host. When Keycloak moves to a new address, for example from a VM to a Kubernetes cluster with a new domain, every provider needs the new URI. Most providers accept several, so register the new one before the switch and remove the old one after.

Staging and production

Use a separate app at the provider, or at least separate redirect URIs, for each environment. That keeps a staging test from sending users to production.

Common errors and fixes

redirect_uri_mismatch or "invalid redirect URI" at the provider

The URI Keycloak sent is not exactly the one registered. Compare them character by character: scheme, host, port, realm and alias all count, and some providers also compare a trailing slash. The redirect_uri parameter in the provider’s error page or in the browser address bar shows what Keycloak sent.

The URI shows http or an internal host

Keycloak builds the URI from its own address. Set hostname to the public URL, and set proxy-headers if a proxy ends TLS in front of Keycloak. The hostname settings helper walks through it.

Unexpected error when authenticating with identity provider

This generic error usually hides a configuration problem after the redirect: a wrong client secret, a mismatched issuer, or a signature check that failed. The Keycloak server log has the detail.

SAML response rejected

Check that the identity provider sends to the ACS URL above, that the entity IDs match on both sides, and that Keycloak has the provider’s current signing certificate.

Security notes

  • Keep the provider’s client secret out of tickets and chat. Store it only in Keycloak.
  • Register exact redirect URIs. Avoid wildcards at providers that allow them.
  • Decide how accounts are linked. Automatic linking by email trusts that the provider has verified the address; only allow it for providers where that is true.
  • Remove redirect URIs for hosts you no longer use, so an old domain cannot be used to receive codes.

Best practices

  • Choose short, stable aliases before you register anything, and write them down.
  • Use one app per provider per environment.
  • Test every provider after a hostname, proxy or domain change.
  • Keep the provider list in the realm small. Each extra button is another trust relationship to maintain.
Questions

Frequently asked questions

What is the Keycloak redirect URI for Google sign-in?

`https://<host>/realms/<realm>/broker/google/endpoint`, if the identity provider’s alias is `google`. Enter it under Authorized redirect URIs of the OAuth client in Google Cloud.

What callback URL does GitHub need for Keycloak?

`https://<host>/realms/<realm>/broker/github/endpoint`, with `github` replaced by your alias if you changed it. Enter it as the Authorization callback URL of the GitHub OAuth app.

What redirect URI do I register in Microsoft Entra ID?

`https://<host>/realms/<realm>/broker/<alias>/endpoint`, added as a Web platform redirect URI in the app registration. The alias is `microsoft` for the built-in Microsoft provider, or whatever you chose for a generic OIDC provider.

Why does the provider say the redirect URI does not match?

The URI must match exactly, including scheme, host, port, realm and alias. Compare it with the `redirect_uri` Keycloak sent, which follows the `hostname` setting.

What is the ACS URL for a SAML identity provider in Keycloak?

The broker endpoint, `https://<host>/realms/<realm>/broker/<alias>/endpoint`. Keycloak’s service provider metadata for that identity provider is at the same URL with `/descriptor` added.

Where does Keycloak show the redirect URI?

On the identity provider’s page in the admin console, once you add it. It is a read-only field you can copy.

Can I change an identity provider’s alias later?

Plan as if you cannot. The alias is part of the redirect URI and of the links between users and the provider, so a different alias in practice means a new identity provider and a new registration at the provider.

Can two identity providers of the same type exist in one realm?

Yes, with different aliases. Each gets its own redirect URI, which you register with its own app at the provider.

Rather not run Keycloak yourself?

We run it for you on a cluster of your own, with backups, upgrades and written support. Starter and Premium begin with a 7-day trial.