2

I am been looking at keycloak documentation, and while I have figured out how to create custom login pages, I can not seem to find the way to send information to keycloak, in the url, about what theme to use. I have a dark theme and a light theme on my website, and I want it so that when the user goes to keycloak from either dark mode or light mode, that keycloak page matches what is from my website. The only thing I found was about some argument to pass in the url of kc_theme='name of theme', but that does not seem to be working.

"http://localhost:8081/realms/customer-portal/protocol/openid-connect/auth?client_id=customer-portal&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fapi%2Flogin-callback&response_type=code&scope=openid&login_theme=my-dark-theme&prompt=login".

What can I do to fix this?

1 Answer 1

0

You should implement the ThemeSelectorProvider and ThemeSelectorProviderFactory SPIs, and then add an entry of the factory to the resources/META-INF/org.keycloak.theme.ThemeSelectorProviderFactory file.

In addition to that, you must enable and tell Keycloak that you want to use your custom implementation as a provider, so, when you invoke your kc.sh you should pass additional arguments, like:

kc.sh build --spi-theme-selector--my-theme-selector-provider--enabled=true --spi-theme-selector--provider=my-theme-selector-provider

You can find more details in the official docs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.