Refresh Creator's Access Token - I'm failing

OK. i figured it out by myself. First of all, I had done
request.get while the mothod was (correctly) stated as “post”.

secondly, the body has to be created a bit differently.

here you go:

var CLIENT_ID = '<ID>'

var CLIENT_SECRET = '<SECRET>'

var token = '<Token- NOT NEEDED FOR REFRESH TOKEN>' 

var refresh_Token =<REFRESH TOKEN>' //

var form = {
    grant_type: 'refresh_token',
    client_id: CLIENT_ID,
    client_secret: CLIENT_SECRET,
    refresh_token: refresh_Token
}

var formData = querystring.stringify(form);
var contentLength = formData.length;

request({
    headers: {
      'Content-Length': contentLength,
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    uri: 'https://www.patreon.com/api/oauth2/token',
    body: formData,
    method: 'POST'
  }, function (err, res, body) {
console.log(body)  
});
3 Likes