Rahul_Goswami wants to implement a logout button outside of Discourse with the same functionality as the built-in logout button. simon suggests using the Discourse API to log users out by making an authenticated POST request to /admin/users/<user_id>/log_out.
To use this API endpoint, simon clarifies that enabling SSO is not required. However, Rahul_Goswami needs to set both the Api-Key and Api-Username headers in the request. If using the All Users API Key, the Api-Username header should be set to ‘system’.
Rahul_Goswami initially encounters a 404 error but resolves the issue with simon’s help, confirming that the solution works.
You can log users out through the Discourse API by making an authenticated POST request to /admin/users/<user_id>/log_out. You need to replace <user_id> with the user’s Discourse user ID.
Hi @simon , i will need to enable sso for this functionality. right? and if yes what are the things i will need to fill/enable for enabling sso just for logout?
You need to set both the Api-Key and Api-Username headers. If you are using the All Users API Key, the Api-Username header should probably be set to ‘system’