Failed to get stream data from Twitch API

For your application you can leave it as http://localhost as you are not using user oAuth.

Your original code seems correct it was just missing the token generation and usage there of