Thanks a lot, #2 helped me to make the script work!
But how can I access the oauth/validate endpoint with the TwitchJS library? It seems to me that I can only access endpoints that follow the https://api.twitch.tv/kraken/<endpoint> scheme. OAuth validation’s endpoint is https://id.twitch.tv/oauth2/validate?