I am using the Twitch Helix API and creating an open source Deno module. I have been trying to test out the API, but whenever I send fetch requests, it returns the following:
{
"error": "Unauthorized",
"status": 401,
"message": "Invalid OAuth token"
}
Here is what I am using within my code for the requests:
await fetch(`https://api.twitch.tv/helix/users?login=${login}`, {
headers: {
"Client-ID": this.apiData.clientId,
Authorization: `OAuth ${this.apiData.clientSecret}`,
},
});
I got my API Client ID and Client Secret from the Twitch Developers Console page for my app. Here are the two keys that I am using:
The code is executed using deno run --allow-net file.ts Do you think that I need to do something else to make sure the request_url is equal to http://localhost for this to be able to work? Also, is it that I need to get a different api key to be able to do this? I also know that my Client ID and Client Secret are correct. I have refreshed them three times already and put the tokens back in and it still doesn’t work.
Please help me figure out what I am doing wrong. Thank you very much for your help!
Check out the Stackoverflow for this here!
Helix uses bearer you specified oauth
await fetch(`https://api.twitch.tv/helix/users?login=${login}`, {
headers: {
"Client-ID": this.apiData.clientId,
Authorization: `OAuth ${this.apiData.clientSecret}`,
},
});
should be
await fetch(`https://api.twitch.tv/helix/users?login=${login}`, {
headers: {
"Client-ID": this.apiData.clientId,
Authorization: `Bearer ${this.apiData.clientSecret}`,
},
});
Thanks, but I still get the same error.
oh I mis read your code
You used your clientSecret as the Authorization token, which is not valid
You need to generate an oAuth token.
The token type depends on the test of your code and what you are doing
Oh, thanks! I’ll try that.
Were do I get an app access token? I tried the Client ID and Client Secret after the OAuth and I’m still getting the error.
system
Closed
8
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.