# With these new changes to API, how exactly this works

**URL:** <https://discuss.dev.twitch.com/t/with-these-new-changes-to-api-how-exactly-this-works/25455>\
**Category:** API\
**Created:** [May 7, 2020, 2:47pm UTC](https://discuss.dev.twitch.com/t/with-these-new-changes-to-api-how-exactly-this-works/25455 "2020-05-07T14:47:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Germel](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/germel/32/8588_2.png) [@Germel](https://discuss.dev.twitch.com/u/Germel)\
**Post date:** [May 7, 2020, 2:47pm UTC](https://discuss.dev.twitch.com/t/with-these-new-changes-to-api-how-exactly-this-works/25455/1 "2020-05-07T14:47:35Z")

</div>

On my Wordpress site I want to check if specific user is live and if it is, get that streamer public info (Steam thumb, title etc) . With this new token requirement I am running into “OAuth token is missing” error.

As I understand, first I need to get the token. Here is how I get token…

```
			$clientId = '123';
			$secret = '456';
			$user = 'anomaly';
			$ch = curl_init(); 
			$url = "https://id.twitch.tv/oauth2/token?client_id=$clientId&client_secret=$secret&grant_type=client_credentials";
			curl_setopt($ch, CURLOPT_URL, $url); 
			curl_setopt($ch, CURLOPT_POST, true);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			$token = curl_exec($ch);

```

It will return me something like this…

```
{"access_token":"REMOVED","expires_in":4845352,"token_type":"bearer"}

```

Next I am going to make request to URL that is supposed to return me the data.

```
			$url = "https://api.twitch.tv/helix/streams?user_login=$user";
			$header = [
				"Client-ID: $clientId",
				"Authorization: Bearer $token->access_token",
			];
			curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
			curl_setopt($ch, CURLOPT_URL, $url);
			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
			$data = curl_exec($ch);
			curl_close($ch);

```

If I now `var_dump` out the `$data` I will get…

```
{"error":"Unauthorized","status":401,"message":"OAuth token is missing"}"
```

---

<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 7, 2020, 2:49pm UTC](https://discuss.dev.twitch.com/t/with-these-new-changes-to-api-how-exactly-this-works/25455/2 "2020-05-07T14:49:43Z")

</div>

Removed your leaked access\_token

```auto
$result = curl_exec($ch);

$token = json_decode($result);

```

Looks like you didn’t JSON Decode the token response before trying to use the token

---

<div class="post-metadata">

**Author:** ![Germel](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/germel/32/8588_2.png) [@Germel](https://discuss.dev.twitch.com/u/Germel)\
**Post date:** [May 7, 2020, 3:01pm UTC](https://discuss.dev.twitch.com/t/with-these-new-changes-to-api-how-exactly-this-works/25455/3 "2020-05-07T15:01:47Z")

</div>

Thanks! Yes it works. I was so close. I earlier used `json_decode`, but removed and did not put it back -.-

---

<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 6, 2020, 3:01pm UTC](https://discuss.dev.twitch.com/t/with-these-new-changes-to-api-how-exactly-this-works/25455/4 "2020-06-06T15:01:50Z")

</div>

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