Hello everyone,
I’m trying to get more control on the logout flow on the frontend. I am not using the javascript adapter.
Currently I’m redirecting my users to the utility logout-redirect endpoint, however I want to control the user experience here and avoid doing redirects.
I’ve tried the backchannel logout endpoint using a public client but I get a CORS error.
The public client web origins is set to *
This is how the request looks:
HEADERS:
- Authorization: Bearer ACCESS_TOKEN
- Content-Type: application/x-www-form-urlencoded
POST <BASE_URL>/auth/realms/REALM/protocol/openid-connect/logout?client_id=public&refresh_token=REFRESH_TOKEN
I’ve been struggling with the documentation to be honest and this is what I put together from multiple stackoverflow posts and old messages from the keycloak mail list.
Hi, I’ve read that one before but I’m not using the js adapters, I’ve updated my question to clarify that.
I couldn’t find there how to do it other than redirecting to the logout endpoint.
Thanks!
Hi @fmayoral this work for me
const refresToken = localStorage.getItem(‘refresh_token’);
const headers = new HttpHeaders({ ‘Content-Type’: ‘application/x-www-form-urlencoded’ });
const body = new URLSearchParams();
body.set(‘client_id’, this.clientId);
body.set(‘refresh_token’, this.refresToken );