Hey, I’m pretty new to API stuff and web development in general and I think I’m a bit lost around that.
I’m trying to make a tool to change my game category, and after reading the documentation I managed to write that down.
I get my “authCode” from the first steps of the OAuth authorization code flow.
var authCode = getUrlQueryStringParamsCode().code;
var params = {
client_id: CLIENT_ID,
client_secret : SECRET,
redirect_uri: REDIRECT_URI,
code : authCode,
grant_type: “authorization_code”,
};var url = https://id.twitch.tv/oauth2/token;
var xhr = new XMLHttpRequest();
xhr.open(“POST”,url);xhr.setRequestHeader(“Accept”, “application/vnd.twitchtv.v5+json”);
xhr.setRequestHeader(“Client-Id”, CLIENT_ID);
xhr.setRequestHeader(“Content-Type”, “application/json”);xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
console.log(xhr.status);
console.log(xhr.responseText);
}};data= encodeQueryString(params);
xhr.send(data);
I get a 400 error for “missing client secret” however I think that I already have the client secret in my request parameters.
I also tryed to put the client secret into the headers but it didn’t work neither. Any idea of what I doing wrong ?
Thanks