# Error with Client-ID

**URL:** <https://discuss.dev.twitch.com/t/error-with-client-id/8671>\
**Category:** API\
**Created:** [January 1, 2017, 2:09am UTC](https://discuss.dev.twitch.com/t/error-with-client-id/8671 "2017-01-01T02:09:54Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![GrimtrisharaLok](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/grimtrisharalok/32/2345_2.png) [@GrimtrisharaLok](https://discuss.dev.twitch.com/u/GrimtrisharaLok)\
**Post date:** [January 1, 2017, 2:09am UTC](https://discuss.dev.twitch.com/t/error-with-client-id/8671/1 "2017-01-01T02:09:54Z")

</div>

I have been coding with jQuery ajax trying to retrieve a channel based off of the OAuth token as seen here.

`$.ajax({
    url: 'https://api.twitch.tv/kraken/channels',
    type: 'GET',
    contentType: 'application/json',
    dataType: 'jsonp',
    headers: {
      'Client-ID': 'xxx',
      'Authorization': token
    }
  });`

and I receive the error

```auto
({"error":"Bad Request","status":400,"message":"No client id specified"})
```

How would I be able to fix this, why am I getting this error?

---

<div class="post-metadata">

**Author:** ![TrainerTimmy](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/trainertimmy/32/1050_2.png) [@TrainerTimmy](https://discuss.dev.twitch.com/u/TrainerTimmy)\
**Post date:** [January 1, 2017, 6:50pm UTC](https://discuss.dev.twitch.com/t/error-with-client-id/8671/2 "2017-01-01T18:50:47Z")

</div>

It looks like you set up your headers wrong. Twitch does not recognize the `Authorization` header, instead you put the OAuth token (without the `oauth:` prefix) under `Client-ID`. Hope my suggestion helps. 😉

---

<div class="post-metadata">

**Author:** ![3ventic](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/3ventic/32/298_2.png) [@3ventic](https://discuss.dev.twitch.com/u/3ventic)\
**Post date:** [January 1, 2017, 8:17pm UTC](https://discuss.dev.twitch.com/t/error-with-client-id/8671/3 "2017-01-01T20:17:38Z")

</div>

Authorization should be 'OAuth ’ + token instead, and you should use a valid client id from an application you registered.

---

<div class="post-metadata">

**Author:** ![GrimtrisharaLok](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/grimtrisharalok/32/2345_2.png) [@GrimtrisharaLok](https://discuss.dev.twitch.com/u/GrimtrisharaLok)\
**Post date:** [January 1, 2017, 11:54pm UTC](https://discuss.dev.twitch.com/t/error-with-client-id/8671/4 "2017-01-01T23:54:46Z")

</div>

I have a vaild Client-ID I just chose to not show it here, because I know what mine is and how to get it.

---

<div class="post-metadata">

**Author:** ![GrimtrisharaLok](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/grimtrisharalok/32/2345_2.png) [@GrimtrisharaLok](https://discuss.dev.twitch.com/u/GrimtrisharaLok)\
**Post date:** [January 1, 2017, 11:55pm UTC](https://discuss.dev.twitch.com/t/error-with-client-id/8671/5 "2017-01-01T23:55:16Z")

</div>

What do you mean by this, if so could you show me an example?

---

<div class="post-metadata">

**Author:** ![TrainerTimmy](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/trainertimmy/32/1050_2.png) [@TrainerTimmy](https://discuss.dev.twitch.com/u/TrainerTimmy)\
**Post date:** [January 2, 2017, 12:10am UTC](https://discuss.dev.twitch.com/t/error-with-client-id/8671/6 "2017-01-02T00:10:19Z")

</div>

It should look like this:

```auto
headers: {
      'Client-ID': 'your OAuth token here'
    }

```

The rest of your code looks fine to me

---

<div class="post-metadata">

**Author:** ![GrimtrisharaLok](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/grimtrisharalok/32/2345_2.png) [@GrimtrisharaLok](https://discuss.dev.twitch.com/u/GrimtrisharaLok)\
**Post date:** [January 2, 2017, 12:16am UTC](https://discuss.dev.twitch.com/t/error-with-client-id/8671/7 "2017-01-02T00:16:33Z")

</div>

I still got the same error, and I have refreshed the caches of the site. Plus when I look at the Docs locatated here [https://dev.twitch.tv/docs/v5/reference/channels/](https://dev.twitch.tv/docs/v5/reference/channels/) it tells me that I need the Authorization, Client-ID, and the Accept Headers

---

<div class="post-metadata">

**Author:** ![TrainerTimmy](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/trainertimmy/32/1050_2.png) [@TrainerTimmy](https://discuss.dev.twitch.com/u/TrainerTimmy)\
**Post date:** [January 2, 2017, 1:01am UTC](https://discuss.dev.twitch.com/t/error-with-client-id/8671/8 "2017-01-02T01:01:40Z")

</div>

I just looked at the docs and you’re right: it needs an extra OAuth token for the `Authorization` header. I’ve tested it myself using the same exact Client ID and got a 404 error. I don’t know how this works exactly, but there’s an alternative method:

1. Get the username’s ID with this URL: `https://api.twitch.tv/kraken/users?login=username`
2. Use that same user ID to get its info, for example, `https://api.twitch.tv/kraken/users/1234567`

It should give you the exact output without the account’s email address, obviously for security reasons. Apologies if it isn’t related, but I find it easier that way.

---

<div class="post-metadata">

**Author:** ![george](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/george/32/120_2.png) [@george](https://discuss.dev.twitch.com/u/george)\
**Post date:** [January 2, 2017, 1:04am UTC](https://discuss.dev.twitch.com/t/error-with-client-id/8671/9 "2017-01-02T01:04:04Z")

</div>

@TrainerTimmy Watch the terminology. Client-ID and OAuth token are not the same.

---

<div class="post-metadata">

**Author:** ![TrainerTimmy](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/trainertimmy/32/1050_2.png) [@TrainerTimmy](https://discuss.dev.twitch.com/u/TrainerTimmy)\
**Post date:** [January 2, 2017, 1:04am UTC](https://discuss.dev.twitch.com/t/error-with-client-id/8671/10 "2017-01-02T01:04:48Z")

</div>

Oh, thanks for pointing that out! 😛

---

<div class="post-metadata">

**Author:** ![TrainerTimmy](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/trainertimmy/32/1050_2.png) [@TrainerTimmy](https://discuss.dev.twitch.com/u/TrainerTimmy)\
**Post date:** [January 2, 2017, 1:08am UTC](https://discuss.dev.twitch.com/t/error-with-client-id/8671/11 "2017-01-02T01:08:58Z")

</div>

@GrimtrisharaLok Try reading this: [https://dev.twitch.tv/docs/v5/guides/authentication/](https://dev.twitch.tv/docs/v5/guides/authentication/)

You can easily get an OAuth token at [http://twitchapps.com/tmi](http://twitchapps.com/tmi). Don’t worry about the name, just about any valid OAuth token linked to an account should work.

---

<div class="post-metadata">

**Author:** ![george](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/george/32/120_2.png) [@george](https://discuss.dev.twitch.com/u/george)\
**Post date:** [January 2, 2017, 1:15am UTC](https://discuss.dev.twitch.com/t/error-with-client-id/8671/12 "2017-01-02T01:15:43Z")

</div>

Try this

```auto
$.ajax({
    url: 'https://api.twitch.tv/kraken/channel',
    type: 'GET',
    contentType: 'application/json',
    dataType: 'json',
    headers: {
      'Client-ID': '<your client id>',
      'Authorization': 'OAuth <your oauth token with channel_read scope>',
      'Accept': 'application/vnd.twitchtv.v5+json'
    }
  });

```

I removed `dataType: jsonp` since Kraken supports CORS so there isn’t much of a need for jsonp. Also, I don’t think that works with headers, added the `Accept` header to specific the latest API version, and also changed the url to remove the “s” in channels. I think there is an error in the v5 docs since this request was singular in previous API versions.

@TrainerTimmy [http://twitchapps.com/tmi](http://twitchapps.com/tmi) is only for generating a token capable of logging into IRC. It will not have the necessary scopes to make the request @GrimtrisharaLok is trying to do.

---

<div class="post-metadata">

**Author:** ![GrimtrisharaLok](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/grimtrisharalok/32/2345_2.png) [@GrimtrisharaLok](https://discuss.dev.twitch.com/u/GrimtrisharaLok)\
**Post date:** [January 2, 2017, 1:27am UTC](https://discuss.dev.twitch.com/t/error-with-client-id/8671/13 "2017-01-02T01:27:44Z")

</div>

Thank you so much @george the issue is now resolved 😃

---

<div class="post-metadata">

**Author:** ![TrainerTimmy](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/trainertimmy/32/1050_2.png) [@TrainerTimmy](https://discuss.dev.twitch.com/u/TrainerTimmy)\
**Post date:** [January 2, 2017, 1:43am UTC](https://discuss.dev.twitch.com/t/error-with-client-id/8671/14 "2017-01-02T01:43:17Z")

</div>

@george 👍

---

<div class="post-metadata">

**Author:** ![3ventic](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/3ventic/32/298_2.png) [@3ventic](https://discuss.dev.twitch.com/u/3ventic)\
**Post date:** [January 2, 2017, 5:16am UTC](https://discuss.dev.twitch.com/t/error-with-client-id/8671/15 "2017-01-02T05:16:14Z")

</div>

dataType json should only make jquery do the JSON.parse for you. jsonp is different.

---

<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 1, 2017, 5:16am UTC](https://discuss.dev.twitch.com/t/error-with-client-id/8671/16 "2017-02-01T05:16:24Z")

</div>

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