When I am trying to hit from my api to authenticate user from keycloak, but its giving me error Invalid parameter: redirect_uri on keycloak page. I have created my own realm
Your redirect URI in your code(keycloak.init) should be the same as the redirect URI set on Keycloak server (client -> Valid Uri)
If you're seeing this problem after you've made a modification to the Keycloak context path, you'll need to make an additional change to a redirect url setting:
<web-context>yourchange/auth</web-context>
back to
<web-context>auth</web-context>
in standalone.xml /auth/admin
) /auth/admin/master/console/*
to
/yourchange/auth/admin/master/console/*
<web-context>yourchange/auth</web-context>
in standalone.xml
Restart Keycloak and navigate to the login page (which is now
/yourchange/auth/admin
) If you are using the Authorization Code Flow then the response_type
query param must be equal to code
. See https://www.keycloak.org/docs/3.3/server_admin/topics/sso-protocols/oidc.html
If you're trying to redirect to the keycloak login page after logout (as I was), that is not allowed by default but also needs to be configured in the "Valid Redirect URIs" setting in the admin console of your client.
You need to check the keycloak admin console for fronted configuration. It must be wrongly configured for redirect url and web origins.
Check that the value of the redirect_uri parameter is whitelisted for the client that you are using. You can manage the configuration of the client via the admin console.
The redirect uri should match exactly with one of the whitelisted redirect uri's, or you can use a wildcard at the end of the uri you want to whitelist. See: https://www.keycloak.org/docs/latest/server_admin/#_clients
Note that using wildcards to whitelist redirect uri's is allowed by Keycloak, but is actually a violation of the OpenId Connect specification. See the discussion on this at https://lists.jboss.org/pipermail/keycloak-dev/2018-December/011440.html