# Getting Data After Redirect

**URL:** <https://discuss.dev.twitch.com/t/getting-data-after-redirect/898>\
**Category:** API\
**Created:** [June 8, 2014, 9:08am UTC](https://discuss.dev.twitch.com/t/getting-data-after-redirect/898 "2014-06-08T09:08:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xSladeHDx](https://avatars.discourse-cdn.com/v4/letter/x/eb8c5e/32.png) [@xSladeHDx](https://discuss.dev.twitch.com/u/xSladeHDx)\
**Post date:** [June 8, 2014, 9:08am UTC](https://discuss.dev.twitch.com/t/getting-data-after-redirect/898/1 "2014-06-08T09:08:35Z")

</div>

So I’m making a website and I’m trying to make a Login via Twitch option. It redirects to Twitch for authentication from the user with all the correct parameters in the URL but when it returns back to my webpage, how do I begin to get data from Twitch with the auth token?

Thanks

---

<div class="post-metadata">

**Author:** ![zAfLu](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/zaflu/32/122_2.png) [@zAfLu](https://discuss.dev.twitch.com/u/zAfLu)\
**Post date:** [June 8, 2014, 1:23pm UTC](https://discuss.dev.twitch.com/t/getting-data-after-redirect/898/2 "2014-06-08T13:23:44Z")

</div>

have you read all the stuff on [https://github.com/justintv/twitch-api](https://github.com/justintv/twitch-api) ?  
All API entrys are included with examples.

---

<div class="post-metadata">

**Author:** ![david](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@david](https://discuss.dev.twitch.com/u/david)\
**Post date:** [June 8, 2014, 8:12pm UTC](https://discuss.dev.twitch.com/t/getting-data-after-redirect/898/3 "2014-06-08T20:12:42Z")

</div>

Depending on what method of authentication you are using, you can go about this in two difference ways.

If you are using the Implicit Grant Flow in which the `access_token` and the `scope` appears in the Fragmented part of a url `http://example.com/twitch.php#access_token=aaaaaaa&scope=user_read`

You will want to read from `document.location.hash` and split the string using the ampersand as the delimiter. Once you have the `access_token` you can include it in the URL’s you request as a parameter of `?oauth_token=` or as a HTTP header of `Authorization: OAuth [access token]`.

As for the Authorization Code Flow, once the user is back on your website, you will have a parameter of `?code=` inside the URL. Use this to perform another request to twitch to obtain the access token. Once you have the access token, use it the same was as the other method.

For full details about authorization, read their API documentation which contains all the information you need at [https://github.com/justintv/Twitch-API/blob/master/authentication.md](https://github.com/justintv/Twitch-API/blob/master/authentication.md)
