I am successfully running a game which connects to Twitch.
Currently I did noit need a valid access token all the time but this is changing now so I probably need to refresh the token during the session.
I am running a nodejs based backend which I am using for handling the authentication stuff (as secrets in delivered assemblies are nerver secret…)
The axios post is posting using the wrong form type.
The documentation specifies data-urlencode, and you/axios are probably sending “multipart/form-data” (instead of “application/x-www-form-urlencoded”) in error causing the problem
Thanks for the headsup @BarryCarlyon! That was the reason.
A cleaner - and WORKING - approach:
var params = new URLSearchParams();
params.append('grant_type', 'refresh_token');
params.append('refresh_token', encodeURIComponent("RefreshTokenDeliveredFromGamesCallLandsHere")); //I am not finally sure if the encode is still required here but it works with it.
params.append('client_id', "mYcLiEnTiD");
params.append('client_secret', "sEcReThErE");
axios.post('https://id.twitch.tv/oauth2/token', params, { responseType: 'json' }).then([...]