# API returning an invalid access token?

**URL:** <https://discuss.dev.twitch.com/t/api-returning-an-invalid-access-token/2188>\
**Category:** API\
**Created:** [May 7, 2015, 12:38am UTC](https://discuss.dev.twitch.com/t/api-returning-an-invalid-access-token/2188 "2015-05-07T00:38:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcacciatore116](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mcacciatore116](https://discuss.dev.twitch.com/u/mcacciatore116)\
**Post date:** [May 7, 2015, 12:38am UTC](https://discuss.dev.twitch.com/t/api-returning-an-invalid-access-token/2188/1 "2015-05-07T00:38:49Z")

</div>

Currently building a quick javascript application and I believe the API is returning an invalid token or my application is not being authenticated properly on Twitch’s end.

Here is the link I am using:

[https://api.twitch.tv/kraken/oauth2/authorize?response\_type=token&client\_id=CLIENT\_ID&redirect\_uri=http://my.domain.com/auth/&scope=user\_read+channel\_subscriptions+channel\_editor+channel\_commercial](https://api.twitch.tv/kraken/oauth2/authorize?response_type=token&client_id=CLIENT_ID&redirect_uri=http://my.domain.com/auth/&scope=user_read+channel_subscriptions+channel_editor+channel_commercial)

Notice that the scope “user\_read” is most definitely in there. That link is definitely working because it brings me to this screen (with all the correct scopes): [http://imgur.com/9u6qs38](http://imgur.com/9u6qs38)

So I login and it redirects me to my redirect URI which looks like:

[http://my.domain.com/auth/#access\_token=ACCESS\_TOKEN&scope=user\_read+channel\_subscriptions+channel\_editor+channel\_commercial](http://my.domain.com/auth/#access_token=ACCESS_TOKEN&scope=user_read+channel_subscriptions+channel_editor+channel_commercial)

There is no redirect mismatch error, or anything like that. It looks like I am authenticated, since it gave me an access token. However, when I try and check to see if the token is valid, using [https://api.twitch.tv/kraken](https://api.twitch.tv/kraken), it shows this: [http://imgur.com/fEnmr98](http://imgur.com/fEnmr98)

Why is the validity showing up as false and why are none of my scopes under “authorization?”

---

<div class="post-metadata">

**Author:** ![mcacciatore116](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mcacciatore116](https://discuss.dev.twitch.com/u/mcacciatore116)\
**Post date:** [May 9, 2015, 2:25am UTC](https://discuss.dev.twitch.com/t/api-returning-an-invalid-access-token/2188/2 "2015-05-09T02:25:53Z")

</div>

Had to use PHP and switch response type to code in order for it to work. So there is definitely something wrong with token as a response type and I would greatly appreciate it if Twitch can look into this for me. I like to avoid PHP as much as I can.

---

<div class="post-metadata">

**Author:** ![night](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/night/32/1613_2.png) [@night](https://discuss.dev.twitch.com/u/night)\
**Post date:** [May 11, 2015, 8:46am UTC](https://discuss.dev.twitch.com/t/api-returning-an-invalid-access-token/2188/3 "2015-05-11T08:46:00Z")

</div>

There is nothing wrong with the implicit authorization method that I can detect. During peak hours access tokens can sometimes take a few seconds to become active. I suggest retrying them a few times to see if that helps.

---

<div class="post-metadata">

**Author:** ![mcacciatore116](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mcacciatore116](https://discuss.dev.twitch.com/u/mcacciatore116)\
**Post date:** [May 12, 2015, 1:28am UTC](https://discuss.dev.twitch.com/t/api-returning-an-invalid-access-token/2188/4 "2015-05-12T01:28:34Z")

</div>

Yeah, its funny. I have about 20 other applications that use implicit authorization and they all work fine. Perhaps you are correct that it is just a peak hours issue. I’ll explore this again in a few days/a week to see if it was just a temporary issue.

---

<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:** [June 11, 2015, 1:28am UTC](https://discuss.dev.twitch.com/t/api-returning-an-invalid-access-token/2188/5 "2015-06-11T01:28:43Z")

</div>

Closed on June 11, 2015, 1:28am UTC

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