# Is there a "log\_in" SSO API endpoint?

**URL:** <https://meta.discourse.org/t/is-there-a-log-in-sso-api-endpoint/33545>\
**Category:** SSO\
**Tags:** rest-api\
**Created:** [September 21, 2015, 9:36pm UTC](https://meta.discourse.org/t/is-there-a-log-in-sso-api-endpoint/33545 "2015-09-21T21:36:00Z")\
**Posts on this page:** 4\
**Page:** 1

## AI-generated summary

The discussion addresses whether an SSO API endpoint exists for logging users into Discourse, similar to the existing logout endpoint. [dradtke](/t/-/33545/1) notes that while logging out via `POST /admin/users/{USER_ID}/log_out` works, attempting to use `/session/sso` for logging in results in a 401 error.

[riking](/t/-/33545/2) explains that servers cannot set cookies for another domain directly. Instead, they suggest embedding the SSO URL in an invisible iframe on a redirect page. This allows the Discourse session to be established via the `session/sso` endpoint, after which the user is redirected to a final destination, such as `/login_finished`.

<div class="post-metadata">

**Author:** ![dradtke](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dradtke/32/116617_2.png) [@dradtke](https://meta.discourse.org/u/dradtke)\
**Post date:** [September 21, 2015, 9:36pm UTC](https://meta.discourse.org/t/is-there-a-log-in-sso-api-endpoint/33545/1 "2015-09-21T21:36:00Z")

</div>

According to [this post](https://meta.discourse.org/t/official-single-sign-on-for-discourse/13045), logging out from an SSO session is as easy as sending a POST request to `/admin/users/{USER_ID}/log_out`, which I managed to get working fairly easily. My question is, is there an equivalent for logging a user in? I tried `/session/sso`, but ended up getting a 401 error.

---

<div class="post-metadata">

**Author:** ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)\
**Post date:** [September 22, 2015, 6:23am UTC](https://meta.discourse.org/t/is-there-a-log-in-sso-api-endpoint/33545/2 "2015-09-22T06:23:09Z")

</div>

You can’t set cookies for another domain from the server, so that wouldn’t work 😛

Try giving the user a page with this on it:

```plaintext
<embed src="https://discourse.example.com/session/sso" onload="window.location='/login_finished'" width=0 height=0>
<div style="display:flex;justify-content:center;align-items:center">
  <div class="loading-spinner">
  <h1>Please wait, logging you into Discourse...</h1>
  <aside><a href="/login_finished">Click here if you don't want to wait</a></aside>
</div>

```

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [November 9, 2018, 2:28am UTC](https://meta.discourse.org/t/is-there-a-log-in-sso-api-endpoint/33545/3 "2018-11-09T02:28:50Z")

</div>

Automatically bumped on November 9, 2018, 2:28am UTC



---

<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:** [November 9, 2018, 6:11am UTC](https://meta.discourse.org/t/is-there-a-log-in-sso-api-endpoint/33545/4 "2018-11-09T06:11:58Z")

</div>

Closed on November 9, 2018, 6:11am UTC


