# Getting authorization\_code via https://api.twitch.tv/api/oauth2/token? stopped working without making any code changes

**URL:** <https://discuss.dev.twitch.com/t/getting-authorization-code-via-https-api-twitch-tv-api-oauth2-token-stopped-working-without-making-any-code-changes/19485>\
**Category:** API\
**Created:** [January 14, 2019, 4:26pm UTC](https://discuss.dev.twitch.com/t/getting-authorization-code-via-https-api-twitch-tv-api-oauth2-token-stopped-working-without-making-any-code-changes/19485 "2019-01-14T16:26:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![JPDP](https://avatars.discourse-cdn.com/v4/letter/j/51bf81/32.png) [@JPDP](https://discuss.dev.twitch.com/u/JPDP)\
**Post date:** [January 14, 2019, 4:26pm UTC](https://discuss.dev.twitch.com/t/getting-authorization-code-via-https-api-twitch-tv-api-oauth2-token-stopped-working-without-making-any-code-changes/19485/1 "2019-01-14T16:26:40Z")

</div>

Hi

I really hope someone can assists. I have read so many articles and nothing speak to what we are experiencing, We created a web site call [streamersguild.net](http://streamersguild.net), in December we update some of the look and flow of the site. We published and all was working fine, tested logon in both our UAT and Prod environments no problem.

As of the beginning of this year (not sure of an exact date) we started getting reports that there is a problem after singing in with your twitch account,

I have been troubleshooting and found that for some reason, (no change made to code) the API call is no longer returning a user ID which result in our cookie being empty then causing all sorts of havoc.

On button click we use the following code:

```auto
Response.Redirect(@"https://api.twitch.tv/kraken/oauth2/authorize?client_id=pv5c21ug6u8neqo2u3rqiyo8uqh838&redirect_uri=http://localhost:58323/loading/twicth/callback&response_type=code&scope=user_read", false);
Context.ApplicationInstance.CompleteRequest();

```

The above is taken from our UAT environment, this successfully takes you to the twitch login and once you enter the correct credentials it successfully redirect with the code in the URL. We then extract and post the following:

```auto
var httpClient = new HttpClient
{
BaseAddress = new Uri(@"https://api.twitch.tv/api/oauth2/token?client_id=pv5c21ug6u8neqo2u3rqiyo8uqh838&client_secret=REMOVED&code=" + CODEGOESHERE + "&grant_type=authorization_code&redirect_uri=http://localhost:58323/loading/twicth/callback")
};
HttpResponseMessage responseMessage = httpClient.PostAsync(httpClient.BaseAddress, null).Result;
responseMessage.EnsureSuccessStatusCode();

```

The above use to work no issue, but now we are getting:  
`{"Response status code does not indicate success: 404 (Not Found)."}`

```auto
{StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  Access-Control-Allow-Origin: *
  Pragma: no-cache
  Twitch-Trace-Id: 2e4fb416d6f88f3179452b68078acc99
  X-Ctxlog-Logid: 1-5c3c9e6e-7b19ac7900ccd2e14c933810
  Timing-Allow-Origin: https://www.twitch.tv
  Connection: close
  Cache-Control: no-store, must-revalidate, no-cache, private
  Date: Mon, 14 Jan 2019 14:36:30 GMT
  Server: nginx
  Content-Length: 67
  Content-Type: application/json; charset=utf-8
  Expires: 0
}}

```

I cannot find any reason for the change in behavior as we have not made any changes to the twitch app config or the code, it was working and now it is not working. Unfortunately I can only confirm that it was defiantly working in December.

Please help…

---

<div class="post-metadata">

**Author:** ![Dist](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/dist/32/7192_2.png) [@Dist](https://discuss.dev.twitch.com/u/Dist)\
**Post date:** [January 14, 2019, 4:38pm UTC](https://discuss.dev.twitch.com/t/getting-authorization-code-via-https-api-twitch-tv-api-oauth2-token-stopped-working-without-making-any-code-changes/19485/2 "2019-01-14T16:38:40Z")

</div>

The URL for exchanging a token should be `https://id.twitch.tv/oauth2/token` as mentioned in the docs [https://dev.twitch.tv/docs/authentication/](https://dev.twitch.tv/docs/authentication/) The authorization URL where you initially redirect the user to is out of date too, so I suggest you update that.

The URL was changed many months ago and deprecated the old URL, so perhaps the issue is that they’ve simply disabled the old URL that has been out of date for many months.

Also, you’ve just disclosed your client secret so you should revoke that secret immediately.

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [January 14, 2019, 5:03pm UTC](https://discuss.dev.twitch.com/t/getting-authorization-code-via-https-api-twitch-tv-api-oauth2-token-stopped-working-without-making-any-code-changes/19485/3 "2019-01-14T17:03:42Z")

</div>

> [@Dist](#):
>
> Also, you’ve just disclosed your client secret so you should revoke that secret immediately.

Edited and removed

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [January 14, 2019, 5:05pm UTC](https://discuss.dev.twitch.com/t/getting-authorization-code-via-https-api-twitch-tv-api-oauth2-token-stopped-working-without-making-any-code-changes/19485/4 "2019-01-14T17:05:30Z")

</div>

TLDR: you should migrate off the old oAuth end points to id.twitch

> **[Getting OAuth Access Tokens](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/)**
>
> Getting OAuth Access Tokens

---

<div class="post-metadata">

**Author:** ![JPDP](https://avatars.discourse-cdn.com/v4/letter/j/51bf81/32.png) [@JPDP](https://discuss.dev.twitch.com/u/JPDP)\
**Post date:** [January 14, 2019, 5:47pm UTC](https://discuss.dev.twitch.com/t/getting-authorization-code-via-https-api-twitch-tv-api-oauth2-token-stopped-working-without-making-any-code-changes/19485/5 "2019-01-14T17:47:04Z")

</div>

> [@Dist](#):
>
> Also, you’ve just disclosed your client secret so you should revoke that secret immediately.

Yup i am aware, test environment, did change it, thanks.

Okay thank you very much, appreciate the quick response. We weren’t expecting anything to change, so are the links we are using from version 3?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [January 14, 2019, 5:54pm UTC](https://discuss.dev.twitch.com/t/getting-authorization-code-via-https-api-twitch-tv-api-oauth2-token-stopped-working-without-making-any-code-changes/19485/6 "2019-01-14T17:54:53Z")

</div>

Technically no, the oAuth routes are not versioned, they just added new ones on id.twitch instead of api.twitch and advised people to move

---

<div class="post-metadata">

**Author:** ![JPDP](https://avatars.discourse-cdn.com/v4/letter/j/51bf81/32.png) [@JPDP](https://discuss.dev.twitch.com/u/JPDP)\
**Post date:** [January 14, 2019, 6:12pm UTC](https://discuss.dev.twitch.com/t/getting-authorization-code-via-https-api-twitch-tv-api-oauth2-token-stopped-working-without-making-any-code-changes/19485/7 "2019-01-14T18:12:09Z")

</div>

Okay great that does clear up the confusion, as we used Kraken in the initial URL we believed it was part of version 5, thanks for the feedback.

---

<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:** [February 13, 2019, 6:12pm UTC](https://discuss.dev.twitch.com/t/getting-authorization-code-via-https-api-twitch-tv-api-oauth2-token-stopped-working-without-making-any-code-changes/19485/8 "2019-02-13T18:12:12Z")

</div>

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