I am building a website where I will need access to finding specific games and streamers a user searches for. In order for me to search for games and streamers, I need to use OAuth Authentication.
It seems to me that I need to use the OAuth client credentials flow.
I have followed the example and am trying to do the API call in Node.js using Express, but I am getting an error called Unexpected token p in JSON at position 4. It seems to be some sort of FetchError but I can not find the solution everywhere. I will link my code below and would appreciate any help I can get! I am ommiting my client_id and client_secret from the code for obvious reasons.
Luckily I tried that before but really don’t get much info from the response. It does show the status as 404 though, but it isn’t hitting the catch error so I am not quite sure what this means.
It worked! OMG thank you! I am wondering why I had to do that. I was sending a POST request from Postman and I had it labeled as router.post in the back end as well so I am wondering why Twitch needed this extra step.
So what is the best approach for using the token? This is the first time I have ever had to do this with an API.
Is it bad to get a token on every API request when I need to access data such as games, channels, etc. from Twitch?