Error 401 Unauthorized | OAuth token is missing

Hi there! I’m a beginner developer and I create a node.js application.
I try to call the games endpoint and always get a 401 error. Here’s an example:

request(
https://api.twitch.tv/helix/games?id=493057, {
headers: {
‘Client-ID’: process.env.TWITCH_CLIENT_ID,
‘Authorization’: process.env.TWITCH_ACCESS_TOKEN,
},
}, (err, res, body) => {
if (err) console.log(err);
console.log(JSON.parse(body));
}
);

Response:
{
error: ‘Unauthorized’,
status: 401,
message: ‘OAuth token is missing’
}

I also tried got library to rich the endpoint with no success. What me confusing is that I can make exactly the same call using Postman with the desired response.

{
“data”: [
{
“id”: “493057”,
“name”: “PLAYERUNKNOWN’S BATTLEGROUNDS”,
“box_art_url”: “https://static-cdn.jtvnw.net/ttv-boxart/PLAYERUNKNOWN’S%20BATTLEGROUNDS-{width}x{height}.jpg
}
]
}

I checked my client ID and recreated my App Access Token and it didn’t help. As I said before, I get success responses using Postman. I also made successful requests with request library to rich other endpoints such as users, streams, followers, and so on. I have a problem only with the games endpoint. Any suggestions?

Should be

‘Authorization’: 'Bearer ' + process.env.TWITCH_ACCESS_TOKEN,
1 Like

Sorry, my mistake. Thank you a lot! :upside_down_face:

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