I’m building out a site, that is meant to grab our streams/recent videos, but I ca’t seem to get ANY of the requests to work… Either I have a problem with verification, or there’s a network error, or what I’m looking for isn’t found.
As is, I get a 404 that our user doesn’t exist… However, in another part of our app, I’m using:
var embed = new Twitch.Embed('MainVideo', {
width: '100%',
height: 480,
channel: '<Same username as before>',
layout: 'video',
});
Which has no problems pulling back our stream if one is going. My problem stems from trying to get our recent videos, The request: https://api.twitch.tv/helix/videos with a header of our client id, requires a user_id… I’m not sure how to get that, I’ve tried GET https://api.twitch.tv/kraken/user But it requires a scope? At which point I decided to turn here, because I’m realizing that I’m way out of my depth here.
The reason for the 404 is because you’re using a v5 endpoint without specifying v5 in the request, so you would need to add the Accept: application/vnd.twitchtv.v5+json header, or api_version=5 as a querystring param.
Alternatively, because v5 is deprecated and being removed at the end of the year, you might want to switch to the new API and use the Helix users endpoint as documented here: https://dev.twitch.tv/docs/api/reference/#get-users
The Helix users endpoint doesn’t require any scope, it has an optional one if you need to get the users email address, but it works without it. Can you show your code that’s giving your an error about missing a required scope?
The id param is to search by user id, it’s not where you supply your apps client id, which is why you’re getting a 401 as you’re not supplying your client id anywhere in the request.
You need to send your client id as the Client-ID header, and then use the login param so you can look up by username.
HTTP.get('https://api.twitch.tv/helix/users', {
params:{
id:'<our client_id (which I was able to find by the request that was working mentioned in my OP)>'
},
headers:{
'Client-ID':'<our client id>',
},
} , (res)=>{
console.log(res)
}
But, Now I can’t figure out how to use the response… The log is getting null