Logout user via Keycloak REST API doesn't work

后端 未结 6 738
余生分开走
余生分开走 2020-12-14 06:55

I have issue while calling Keycloak\'s logout endpoint from an (mobile) application.

This scenario is supported as stated in its documentation:

6条回答
  •  暖寄归人
    2020-12-14 07:25

    Finally, I've found the solution by looking at the Keycloak's source code: https://github.com/keycloak/keycloak/blob/9cbc335b68718443704854b1e758f8335b06c242/services/src/main/java/org/keycloak/protocol/oidc/endpoints/LogoutEndpoint.java#L169. It says:

    If the client is a public client, then you must include a "client_id" form parameter.

    So what I was missing is the client_id form parameter. My request should have been:

    POST http://localhost:8080/auth/realms//protocol/openid-connect/logout
    Authorization: Bearer 
    Content-Type: application/x-www-form-urlencoded
    
    client_id=&refresh_token=
    

    The session should be destroyed correctly.

提交回复
热议问题