How to change identity provider callback URL in Keycloak

2/10/2020

I have a Keycloak server hosted in Kubernetes. When I request to external identity provider (like Google/Facebook), the hostname was used in the redirect url automatically. How can I change the redirect URL for my identity provider?

The auto generated redirect_url from Keycloak: http://keyclaok:8080/auth/realms/{MY_REALM}/borker/google/endpoint

What I'm expected: http://www.example.com/my-custom-callback/endpoint, this url will redirect to the original keyclaok endpoint.

My identity provider settings in Keycloak

-- Kelvin Lee
google-oauth
keycloak
kubernetes

1 Answer

2/10/2020

The auto_generated redirect_url (shown in the UI) should not be relevant for you.

Afaik keycloak just build up the url with the current hostname you are accessing keycloak. So when you access your admin console via

http://keyclaok:8080/

Redirect URL for a google Identity Provider is shown as

http://keyclaok:8080/auth/realms/{MY_REALM}/broker/google/endpoint

If you access keycloak over your domain

http://www.example.com/auth

and try to authenticate over google, the valid redirect URL will be

http://www.example.com/auth/realms/{MY_REALM}/broker/google/endpoint

In my opinion you can't decide how the redirect url will look like (especially not the suffix realms/{MY_REALM}/broker/google/endpoint), because it's relative to the keycloak base URL and keycloak needs it internally to map a answer to the correct realm and IDP But I think you shouldn't have a problem with such a url, as long as keycloak is accessible over your domain

-- Evil_skunk
Source: StackOverflow