LoginSignup
20
15

More than 5 years have passed since last update.

KeycloakのLogout Endpointでログアウトする

Posted at

ユーザーがアプリケーションからKeycloakにSingle Sign-Onしたあと、アプリケーションだけでなくKeycloakからもログアウトしたい場合。

公式ドキュメントによると、下記のURLにアクセスすればいいと書かれています。

http://サーバー名:ポート/auth/realms/レルム名/protocol/openid-connect/logout

しかしドキュメントには、GETなのかPOSTなのか、必要なパラメーターは何なのか、パラメーターはヘッダーで送るのかクエリパラメーターなのか何なのか、何も書かれていない・・・。

色々試した結果、分かりました。

メソッドはPOST、そしてリクエストパラメーターとして refresh_tokenclient_idclient_secret を送信すればログアウトできます。

curlコマンドだとこんな感じです。

curl -v -X POST -H "Content-Type: x-www-form-urlencoded" -d "refresh_token=リフレッシュトークン" -d "client_id=クライアントID" -d "client_secret=クライアントシークレット" http://サーバー名:ポート/auth/realms/レルム名/protocol/openid-connect/logout
20
15
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
15