# How do i add a "Login with Twitch" button to my website?

**URL:** <https://discuss.dev.twitch.com/t/how-do-i-add-a-login-with-twitch-button-to-my-website/9674>\
**Category:** API\
**Created:** [March 17, 2017, 11:40am UTC](https://discuss.dev.twitch.com/t/how-do-i-add-a-login-with-twitch-button-to-my-website/9674 "2017-03-17T11:40:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@Andrews](https://discuss.dev.twitch.com/u/Andrews)\
**Post date:** [March 17, 2017, 11:40am UTC](https://discuss.dev.twitch.com/t/how-do-i-add-a-login-with-twitch-button-to-my-website/9674/1 "2017-03-17T11:40:32Z")

</div>

Hi everyone, i would like to add a login with Twitch button to my website because i need to store in my DB the twitch id and username of the person who’s logging in.

I tried following the guides for the API but probably i’m not smart enough to make it work.

Any help is appreciated!

Thanks

---

<div class="post-metadata">

**Author:** ![Addramyr2012](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/addramyr2012/32/2621_2.png) [@Addramyr2012](https://discuss.dev.twitch.com/u/Addramyr2012)\
**Post date:** [March 17, 2017, 5:51pm UTC](https://discuss.dev.twitch.com/t/how-do-i-add-a-login-with-twitch-button-to-my-website/9674/2 "2017-03-17T17:51:59Z")

</div>

Making a link to create a login button is really simple.

All you need to do is make a link on your webpage/app

E.g.  
‹a href=“[https://api.twitch.tv/kraken/oauth2/authorize?response\_type=code&client\_id=[YOUR\_PUBLIC\_CLIENT\_ID]&redirect\_uri=[RETURN\_URL]&scope=[SCOPES\_REQUIRES]](https://api.twitch.tv/kraken/oauth2/authorize?response_type=code&client_id=%5BYOUR_PUBLIC_CLIENT_ID%5D&redirect_uri=%5BRETURN_URL%5D&scope=%5BSCOPES_REQUIRES%5D)”›Connect With Twitch!‹/a›

Once the user clicks the link they goto Twitch. After they approve it redirect back the RETURN\_URL you specified and you can process details such as auth key and run futher API calls using it as reference.

---

<div class="post-metadata">

**Author:** ![Andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@Andrews](https://discuss.dev.twitch.com/u/Andrews)\
**Post date:** [March 17, 2017, 6:08pm UTC](https://discuss.dev.twitch.com/t/how-do-i-add-a-login-with-twitch-button-to-my-website/9674/3 "2017-03-17T18:08:38Z")

</div>

Thanks for the answer but i still can’t make it work, that’s what i get as response: {“error”:“Bad Request”,“status”:400,“message”:“No client id specified”}

---

<div class="post-metadata">

**Author:** ![Addramyr2012](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/addramyr2012/32/2621_2.png) [@Addramyr2012](https://discuss.dev.twitch.com/u/Addramyr2012)\
**Post date:** [March 17, 2017, 6:10pm UTC](https://discuss.dev.twitch.com/t/how-do-i-add-a-login-with-twitch-button-to-my-website/9674/4 "2017-03-17T18:10:53Z")

</div>

Goto [https://www.twitch.tv/settings/connections](https://www.twitch.tv/settings/connections) scroll to the bottom and click Register your application.

Give it all the requested details and you will get back your client ids

---

<div class="post-metadata">

**Author:** ![Andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@Andrews](https://discuss.dev.twitch.com/u/Andrews)\
**Post date:** [March 17, 2017, 6:12pm UTC](https://discuss.dev.twitch.com/t/how-do-i-add-a-login-with-twitch-button-to-my-website/9674/5 "2017-03-17T18:12:26Z")

</div>

I did it. that’s the line modified : [https://api.twitch.tv/kraken/oauth2/authorize?response\_type=code&client\_id=[wds8du7dz7ub3l76bx4bbjrrkuldng]&redirect\_uri=[http://localhost/twitchapp/index.php]&scope=[user\_read]](https://api.twitch.tv/kraken/oauth2/authorize?response_type=code&client_id=%5Bwds8du7dz7ub3l76bx4bbjrrkuldng%5D&redirect_uri=%5Bhttp://localhost/twitchapp/index.php%5D&scope=%5Buser_read%5D)

And it’s still not working, don’t know if i’m doing something wrong

---

<div class="post-metadata">

**Author:** ![Addramyr2012](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/addramyr2012/32/2621_2.png) [@Addramyr2012](https://discuss.dev.twitch.com/u/Addramyr2012)\
**Post date:** [March 17, 2017, 6:56pm UTC](https://discuss.dev.twitch.com/t/how-do-i-add-a-login-with-twitch-button-to-my-website/9674/6 "2017-03-17T18:56:23Z")

</div>

Ahh, remove the [and] example:

[https://api.twitch.tv/kraken/oauth2/authorize?response\_type=code&client\_id=wds8du7dz7ub3l76bx4bbjrrkuldng&redirect\_uri=http://localhost/twitchapp/index.php&scope=user\_read](https://api.twitch.tv/kraken/oauth2/authorize?response_type=code&client_id=wds8du7dz7ub3l76bx4bbjrrkuldng&redirect_uri=http://localhost/twitchapp/index.php&scope=user_read)

---

<div class="post-metadata">

**Author:** ![Andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@Andrews](https://discuss.dev.twitch.com/u/Andrews)\
**Post date:** [March 17, 2017, 6:58pm UTC](https://discuss.dev.twitch.com/t/how-do-i-add-a-login-with-twitch-button-to-my-website/9674/7 "2017-03-17T18:58:12Z")

</div>

Oh! it’s finally working!!!

Thanks a lot dude!

I just need to figure out how to get the parameters that i need after the login, how can i do that?

---

<div class="post-metadata">

**Author:** ![billygerhard](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/billygerhard/32/3983_2.png) [@billygerhard](https://discuss.dev.twitch.com/u/billygerhard)\
**Post date:** [March 20, 2017, 6:28pm UTC](https://discuss.dev.twitch.com/t/how-do-i-add-a-login-with-twitch-button-to-my-website/9674/8 "2017-03-20T18:28:27Z")

</div>

That all depends on what code you are using to create your page. Javascript, PHP, etc. Each code will have different methods to retrieve the parameters. It looks like you are using PHP from your sample URL. The best option would be to google it, as retrieving parameters are global across PHP, it isn’t specific to Twitch’s API.

---

<div class="post-metadata">

**Author:** ![Andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@Andrews](https://discuss.dev.twitch.com/u/Andrews)\
**Post date:** [March 26, 2017, 11:28am UTC](https://discuss.dev.twitch.com/t/how-do-i-add-a-login-with-twitch-button-to-my-website/9674/9 "2017-03-26T11:28:27Z")

</div>

i figured out how to retrieve the data with JS but i’ve no idea about how can i store that data in a DB.

Could someone help?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [April 25, 2017, 11:30am UTC](https://discuss.dev.twitch.com/t/how-do-i-add-a-login-with-twitch-button-to-my-website/9674/10 "2017-04-25T11:30:04Z")

</div>

Closed on April 25, 2017, 11:30am UTC

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