# Receiving 401 (Unauthorized)

**URL:** <https://discuss.dev.twitch.com/t/receiving-401-unauthorized/25889>\
**Category:** API\
**Created:** [May 24, 2020, 7:30pm UTC](https://discuss.dev.twitch.com/t/receiving-401-unauthorized/25889 "2020-05-24T19:30:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lucas\_Izumi](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/lucas_izumi/32/8817_2.png) [@Lucas\_Izumi](https://discuss.dev.twitch.com/u/Lucas_Izumi)\
**Post date:** [May 24, 2020, 7:30pm UTC](https://discuss.dev.twitch.com/t/receiving-401-unauthorized/25889/1 "2020-05-24T19:30:51Z")

</div>

Hello guys, I’m new to this and I’m just trying to fetch some data using the API, but I keep receiving error 401. My Client-ID is correct, I don’t know what else it could be. Can you guys see if there is something wrong with my code?

```
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
function GetGame(){
    var result = [];
    
    $.ajax({
      type: 'GET',
      url: 'https://api.twitch.tv/helix/streams?game_id=33214',
      headers: {
        "Client-ID" : "MY_ID_HERE",
        "Accept": "application/vnd.twitchtv.v5+json"
      },
      success: function(json) {
        result.push(json.streams);
        console.log(json);
        console.log(result);
    }});

    return result;
}

GetGame();
</script>
```

---

<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:** [May 24, 2020, 7:31pm UTC](https://discuss.dev.twitch.com/t/receiving-401-unauthorized/25889/2 "2020-05-24T19:31:27Z")

</div>

Are you obtaining and using an oAuth token?

---

<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:** [May 24, 2020, 7:32pm UTC](https://discuss.dev.twitch.com/t/receiving-401-unauthorized/25889/3 "2020-05-24T19:32:05Z")

</div>

- You don’t need the v5 header with helix
- You don’t have an oAuth token, Helix requires an oAuth token

---

<div class="post-metadata">

**Author:** ![Lucas\_Izumi](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/lucas_izumi/32/8817_2.png) [@Lucas\_Izumi](https://discuss.dev.twitch.com/u/Lucas_Izumi)\
**Post date:** [May 24, 2020, 7:33pm UTC](https://discuss.dev.twitch.com/t/receiving-401-unauthorized/25889/4 "2020-05-24T19:33:21Z")

</div>

I’m following step 2 from this doc [https://dev.twitch.tv/docs/api](https://dev.twitch.tv/docs/api) it does not mention an oAuth token. Where should I find about this?:

---

<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:** [May 24, 2020, 7:34pm UTC](https://discuss.dev.twitch.com/t/receiving-401-unauthorized/25889/5 "2020-05-24T19:34:18Z")

</div>

![image](https://d2opxh93rbxzdn.cloudfront.net/original/2X/5/58df5619ef0c20d94b0fbca8e1d4ed91fe982779.png)

You missed the header at the top.

Some of the documentation has not been updated to account for the recent changes to the API

---

<div class="post-metadata">

**Author:** ![Lucas\_Izumi](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/lucas_izumi/32/8817_2.png) [@Lucas\_Izumi](https://discuss.dev.twitch.com/u/Lucas_Izumi)\
**Post date:** [May 24, 2020, 7:35pm UTC](https://discuss.dev.twitch.com/t/receiving-401-unauthorized/25889/6 "2020-05-24T19:35:02Z")

</div>

My bad, Thanks for pointing it out!

---

<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:** [May 24, 2020, 7:36pm UTC](https://discuss.dev.twitch.com/t/receiving-401-unauthorized/25889/7 "2020-05-24T19:36:30Z")

</div>

No problem!

---

<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 23, 2020, 7:44pm UTC](https://discuss.dev.twitch.com/t/receiving-401-unauthorized/25889/8 "2020-06-23T19:44:39Z")

</div>

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