# Logout POST Request

**URL:** https://meta.discourse.org/t/logout-post-request/192601
**Category:** SSO
**Created:** [June 3, 2021, 8:39pm UTC](https://meta.discourse.org/t/logout-post-request/192601 "2021-06-03T20:39:53Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Bio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bio/32/198067_2.png) [@Bio](https://meta.discourse.org/u/Bio)
#### Post date: [June 3, 2021, 8:39pm UTC](https://meta.discourse.org/t/logout-post-request/192601/1 "2021-06-03T20:39:53Z")

</div>

Hi, I’ve recently been trying to create a single sign out system where I can log off on my website and it will automatically log the user off of their Discourse account as well. According to this website [https://meta.discourse.org/t/discourseconnect-official-single-sign-on-for-discourse-sso/13045](https://meta.discourse.org/t/discourseconnect-official-single-sign-on-for-discourse-sso/13045)

> **Logging off users**  
> You can use the POST admin endpoint `/admin/users/{USER_ID}/log_out` to log out any user in the system if needed.  
> To configure the endpoint Discourse redirects to on logout search for the `logout redirect` setting. If no URL has been set here you will be redirected back to the URL configured in `discourse connect url` .

I’ve created an API key to accomplish this, then made a POST request using [https://reqbin.com/](https://reqbin.com/) to `https://MY_DISCOURSE_DOMAIN/admin/users/USER_ID/log_out?api_key=XXXXXXXXXXXXXXXXXXXXXX&api_username=system`  
For my API key, I allowed system to be my user. If anyone could give me some guidance as to why this isn’t working, it would be greatly appreciated.

---

<div class="post-metadata">

### Author: ![Bio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bio/32/198067_2.png) [@Bio](https://meta.discourse.org/u/Bio)
#### Post date: [June 3, 2021, 9:41pm UTC](https://meta.discourse.org/t/logout-post-request/192601/2 "2021-06-03T21:41:12Z")

</div>

I’ve figured it out, so I will leave the link to the other forum here so others like me can have an easier time trying to implement this. It turns out that the other topics that suggest you put your api\_key and api\_username in the URL were invalidated about half a year ago. The new way to make the POST request is to follow the steps in the following [forum](https://meta.discourse.org/t/discourse-api-documentation/22706).

In my case, I logged someone out by making the following curl request:

```plaintext
curl -X POST "https://DICOURSE-WEBSITE/admin/users/USER-ID/log_out" -H "Content-Type: multipart/form-data;" -H "Api-Key: INSERT-API-KEY" -H "Api-Username: INSERT-API-USERNAME"

```

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [June 3, 2021, 9:42pm UTC](https://meta.discourse.org/t/logout-post-request/192601/3 "2021-06-03T21:42:39Z")

</div>

Glad to hear you got it working!

> [@Bio](#):
>
> the other topics that suggest you put your api\_key and api\_username in the URL were invalidated about half a year ago

Would you mind sharing links to the outdated topics, so that we can update/delete them?

---

<div class="post-metadata">

### Author: ![Bio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bio/32/198067_2.png) [@Bio](https://meta.discourse.org/u/Bio)
#### Post date: [June 3, 2021, 10:08pm UTC](https://meta.discourse.org/t/logout-post-request/192601/4 "2021-06-03T22:08:19Z")

</div>

Here is the outdated topic [https://meta.discourse.org/t/how-to-obtain-the-user-id-so-i-can-issue-a-logout-api-call/102033/5](https://meta.discourse.org/t/how-to-obtain-the-user-id-so-i-can-issue-a-logout-api-call/102033/5). The other topics only seemed outdated because I had just read this one.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [June 4, 2021, 7:48am UTC](https://meta.discourse.org/t/logout-post-request/192601/5 "2021-06-04T07:48:48Z")

</div>

Thanks, I’ve added a couple of notes to that topic

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [June 5, 2021, 7:00am UTC](https://meta.discourse.org/t/logout-post-request/192601/6 "2021-06-05T07:00:02Z")

</div>

This topic was automatically closed after 23 hours. New replies are no longer allowed.
