# SSO Logout via Master API Key isn't working

**URL:** https://meta.discourse.org/t/sso-logout-via-master-api-key-isnt-working/56485
**Category:** Support
**Created:** [January 27, 2017, 7:30pm UTC](https://meta.discourse.org/t/sso-logout-via-master-api-key-isnt-working/56485 "2017-01-27T19:30:50Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![n4ru](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@n4ru](https://meta.discourse.org/u/n4ru)
#### Post date: [January 27, 2017, 7:30pm UTC](https://meta.discourse.org/t/sso-logout-via-master-api-key-isnt-working/56485/1 "2017-01-27T19:30:50Z")

</div>

```
    discourseId = json.loads(urlopen('http://example.com/users/by-external/' + str(g.user_id) + '.json').read().decode('utf-8'))['user']['id']
    # This doesn't work and I have no idea why
    urlopen("http://example.com/admin/users/" + str(discourseId) + "/log_out?api_key=2345139133012345678909de3a3a4fc3ed01abcdef347b983667b0b1f00efb25&api_username=system")

```

Not my actual API key.

I’ve verified that the user\_id passed to discourseId is correct, and I’m able to run the log\_out endpoint with no error, it just doesn’t work! I’ve also tried using the actual user in place of system, to no avail.

Am I missing something?

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [January 27, 2017, 8:48pm UTC](https://meta.discourse.org/t/sso-logout-via-master-api-key-isnt-working/56485/2 "2017-01-27T20:48:41Z")

</div>

It works if it’s a POST request. Try passing the api\_key and api\_username as data.

---

<div class="post-metadata">

### Author: ![n4ru](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@n4ru](https://meta.discourse.org/u/n4ru)
#### Post date: [January 27, 2017, 9:53pm UTC](https://meta.discourse.org/t/sso-logout-via-master-api-key-isnt-working/56485/3 "2017-01-27T21:53:07Z")

</div>

That worked. Thanks a bunch.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [January 30, 2017, 1:28am UTC](https://meta.discourse.org/t/sso-logout-via-master-api-key-isnt-working/56485/4 "2017-01-30T01:28:46Z")

</div>


