Keycloak Logout Request

Stack picture Stack · May 9, 2016 · Viewed 33.7k times · Source

I wanted to ask if there is a way to logout from keycloak via a single http request.

I already tried to POST /protocol/openid-connect/logout or /tokens/logout, but the result is always a ORIGIN-Problem.

But the calling ORIGIN is configured in keycloak and the login with a request works.

Any chance here to logout without redirecting or open another window?

Best regards and thanks! :)

Answer

aName picture aName · Aug 18, 2016

From the official documentation:

You can log out of a web application in multiple ways. For Java EE servlet containers, you can call HttpServletRequest.logout().

For other browser applications, you can redirect the browser to http://auth-server/auth/realms/{realm-name}/protocol/openid-connect/logout?redirect_uri=encodedRedirectUri, which logs you out if you have an SSO session with your browser.

To get the exact URL of the app (host, realm and redirect_uri configuration):

  • Log in to your Keycloak user account
  • Open up the developer console of the browser
  • Perform the logout operation
  • Note down the URL that was used to request for logout
  • Use the same URL from your application to perform the logout