Login with twitch returning unreadable text

Been trying to create a login with twitch button on my website for a few days now with node.js, I have managed to get the token from twitch using the code from the authentication, however it just sends back a load of unreadable text.
This is what i am getting back from my post request:
image

That response is likely due to compression, so you’ll need to set whatever module it is you’re using to make the request decompress the response.

Assuming nodejs with request

request({
    url: 'THEURL',
    method: 'POST',
    gzip: true,
    json: true
}, function(e,r,b) {
});

You probably did not get r.statusCode being a 200

Im using the request module with the promise module. Also the response code i am getting is 403 if this helps:


ive tried decompressing the response but cant seem to get anywhere with it, anything you can suggest?

The body will contain the error message solve the error message and away you go!

Thanks for the suggestion Barry but if i knew how to solve the error i wouldn’t have asked on here.

Add gzip: true to your options…

I’ve tried that as well, im now receiving a buffer. However, i cannot decode it.

may work

new Buffer(input).toString()

I don’t use the promise version of request, but if you have a “buffer” that should do it

Thanks for the help, this has helped me decode the response from twitch, however i am getting an error code from the server:
image
I am not sure what is wrong with my request but i have tried many things and i cannot get a correct response from twitch

Have you made sure your client id, secret and redirect being sent in the querystring match exactly to whats listed for your app in the dev dashboard? A good way to make sure would be to look at the response object as that will contain exactly what was sent.

FINALLY GOT IT TO WORK
thanks for the help guys, turns out my client secret was no longer valid and i had to get a new one

If you haven’t already done so, you need to revoke that token right now. You shouldn’t be making them public, it is your responsibility to ensure they are properly stored and remain private.

my bad, its been a long day. ill change it now

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