# Authenticate user when they login from chat iframe

**URL:** <https://staging-discuss.dev.twitch.com/t/authenticate-user-when-they-login-from-chat-iframe/7491>\
**Category:** API\
**Created:** [September 18, 2016, 11:53pm UTC](https://staging-discuss.dev.twitch.com/t/authenticate-user-when-they-login-from-chat-iframe/7491 "2016-09-18T23:53:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![VincentRichard555](https://avatars.discourse-cdn.com/v4/letter/v/8797f3/32.png) [@VincentRichard555](https://staging-discuss.dev.twitch.com/u/VincentRichard555)\
**Post date:** [September 18, 2016, 11:53pm UTC](https://staging-discuss.dev.twitch.com/t/authenticate-user-when-they-login-from-chat-iframe/7491/1 "2016-09-18T23:53:46Z")

</div>

I am using the chat iframe and would like to be able to authenticate users from their logging in to the chat. Currently, I authenticate using the procedure here:

> **[justintv/twitch-js-sdk](https://github.com/justintv/twitch-js-sdk)**
>
> Contribute to twitch-js-sdk development by creating an account on GitHub.

where the login is done via:

$(’.twitch-connect’).click(function() {  
Twitch.login({  
redirect\_uri: REDIRECT\_URI,  
scope: [‘user\_read’, ‘channel\_read’]  
});  
})  
Is there a way to do this when the user logs in to the chat as well? It seems silly to log in via chat and then have to log in by clicking the button as well.

Thanks

---

<div class="post-metadata">

**Author:** ![DallasNChains](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/dallasnchains/32/1608_2.png) [@DallasNChains](https://staging-discuss.dev.twitch.com/u/DallasNChains)\
**Post date:** [September 19, 2016, 12:04am UTC](https://staging-discuss.dev.twitch.com/t/authenticate-user-when-they-login-from-chat-iframe/7491/2 "2016-09-19T00:04:56Z")

</div>

No, there isn’t a way to use the authentication from the chat embed. The iframe is on another domain, and the cookies and authentication information aren’t shared for security reasons.

---

<div class="post-metadata">

**Author:** ![VincentRichard555](https://avatars.discourse-cdn.com/v4/letter/v/8797f3/32.png) [@VincentRichard555](https://staging-discuss.dev.twitch.com/u/VincentRichard555)\
**Post date:** [September 21, 2016, 4:07am UTC](https://staging-discuss.dev.twitch.com/t/authenticate-user-when-they-login-from-chat-iframe/7491/3 "2016-09-21T04:07:57Z")

</div>

Thanks for the reply. Is there a way using the API to authenticate users who log into chat without using the iframe?

Currently, I authenticate them with a button and don’t want them to have to log in twice (once for my site, and once for the chat).

Thanks

---

<div class="post-metadata">

**Author:** ![DallasNChains](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/dallasnchains/32/1608_2.png) [@DallasNChains](https://staging-discuss.dev.twitch.com/u/DallasNChains)\
**Post date:** [September 21, 2016, 7:21pm UTC](https://staging-discuss.dev.twitch.com/t/authenticate-user-when-they-login-from-chat-iframe/7491/4 "2016-09-21T19:21:38Z")

</div>

How are you embedding chat? The chat embeds should use the currently logged in Twitch user, so there shouldn’t be a double login.

To answer your question directly: there is no API for logging a user in. Just the two auth flows in the documentation.

---

<div class="post-metadata">

**Author:** ![VincentRichard555](https://avatars.discourse-cdn.com/v4/letter/v/8797f3/32.png) [@VincentRichard555](https://staging-discuss.dev.twitch.com/u/VincentRichard555)\
**Post date:** [September 25, 2016, 6:48am UTC](https://staging-discuss.dev.twitch.com/t/authenticate-user-when-they-login-from-chat-iframe/7491/5 "2016-09-25T06:48:58Z")

</div>

Yes that is correct.

If the user is auth’d from my site then they are automatically logged in.

However, it is case two that is annoying. They log in to the chat before being auth’d by my site, in which case they would have to be auth’d by my site as well (2 log ins).

Perhaps I could force a log in before they get to my site, but I don’t want to do this.

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://d2spem0quai2ol.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://staging-discuss.dev.twitch.com/u/system)\
**Post date:** [October 25, 2016, 6:49am UTC](https://staging-discuss.dev.twitch.com/t/authenticate-user-when-they-login-from-chat-iframe/7491/6 "2016-10-25T06:49:04Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
