Hey everyone!
I’m trying to add required config to my extension.
I have the Authentication header sorted with no problems however i keep getting a error 400 No client ID specified when i do a call to:
$url = “https://api.twitch.tv/extensions/MY_ID/0.0.1/required_configuration?channel_id=CHANNEL_ID”
Below is a small section of the code used to make the request.
$headers = array(
‘Authorization’ => 'Bearer '.$extension->getAuthentication(),
‘Client-ID’ => TwitchExtension::$API_CLIENT,
‘Content-Type’ => ‘application/json’,
);
$resp = self::curlIt($headers, $post, $url)
The response i get back from Twitch:
{“error”:“Bad Request”,“status”:400,“message”:“No client id specified”}
If anyone has some ideas it will be greatly appreciated!
-Addramyr
Ok, so fixed the issue with client id… this was fixed by adding &client_id as query parameter.
Next Problem… Seems my earlier luck with the JWT authentication was a failure.
My new error response:
{“error”:“Unauthorized”,“status”:401,“message”:“authentication failed”}
Language: PHP
Engine: Firebase JWT (https://github.com/firebase/php-jwt)
PHP Code
Below is the JWT code used to generate a signature…
public function auth($userId) {
$payload = array(
“exp” => (int) time() + 60,
“user_id” => (string) ‘’.$userId.’’,
“role” => “external”,
);
return JWT::encode($payload, SystemConfig::$API_SECRET, ‘HS256’);
}
When you specify a Auth it overrides clientID as under Kraken, the oauth key is used to look up the clientID for it.
However your PHP Code is wrong.
For cURL headers should be:
$headers = array(
'Authorization: Bearer '.$extension->getAuthentication(),
'Content-Type: application/json'
);
So the headers you are passing are completely wrong. (Note I omitted Client-ID here, but personally I leave it in all the time)
http://php.net/curl_setopt
No need for the CLientID in the URL/query string, just fix your header sending
Revise: Make sure you have a
curl_setopt($ch, CURLOPT_PUT, true);
In there somewhere