# Log in a user via the API

**URL:** <https://meta.discourse.org/t/log-in-a-user-via-the-api/42862>\
**Category:** SSO\
**Created:** [20 Aprile 2016, 8:02am UTC](https://meta.discourse.org/t/log-in-a-user-via-the-api/42862 "2016-04-20T08:02:42Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)\
**Post date:** [20 Aprile 2016, 12:56pm UTC](https://meta.discourse.org/t/log-in-a-user-via-the-api/42862/4 "2016-04-20T12:56:46Z")

</div>

This is tricky to do – the API alone cannot do it, because you need to set a cookie.

I’d try embedding the login-route in an invisible iframe once after the user logs in – but that’s an ugly hack.

---

_[View the full topic](https://meta.discourse.org/t/log-in-a-user-via-the-api/42862)._
