Issues with new api OAuth

So I used twitch validate to confirm that my token is valid…

$streamurl = "https://api.twitch.tv/helix/streams?user_login=<login_name>";

function file_get_channelcontents_curl($streamurl) {
	$streamch = curl_init();
        curl_setopt($streamch, CURLOPT_URL, $streamurl);
        curl_setopt($streamch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($streamch, CURLOPT_CUSTOMREQUEST, 'GET');

        $streamheaders = array();
        $streamheaders[] = 'Client-Id: <client-id-here>, Authorization: OAuth <oauth-here>';
        curl_setopt($streamch, CURLOPT_HTTPHEADER, $streamheaders);

        $streamresult = curl_exec($streamch);
            if (curl_errno($streamch)) {
                echo 'Error:' . curl_error($streamch);
            }
        curl_close($streamch);

		return $streamresult;
}

echo file_get_channelcontents_curl($streamurl);

And I get:
{“error”:“Unauthorized”,“status”:401,“message”:“OAuth token is missing”}

What am I doing wrong here?

You should use Bearer <oauth-here>

See: Authentication | Twitch Developers

I tried that also, same response.

Is your Oauth token valid? You just generated it and you are not using your app secret instead of using an oauth token?

        $streamheaders[] = 'Client-Id: <client-id-here>, Authorization: OAuth <oauth-here>';

is wrong

$streamheaders[] = 'Client-Id: <client-id-here>';
$streamheaders[] = 'Authorization: Bearer <oauth-here>';

is correct

OMG thank you so much! I have been stuck on this for a while now and I knew it was something to do with the php.
Happy Dance

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