Hello,
I come close this topic so I found a solution. Not as you would like but it works.
I was using Node’s native HTTPS module to make the request, I believe that due to lack of knowledge I must have missed some configuration and this was preventing my request.
To solve I used the third party module ‘request’, with this module everything happened normally. Below is the call to the API with the request module.
function refreshToken(refresh_token, clienInfo) {
var promise = new Promise(function (resolve, reject) {
var data = {
grant_type: 'refresh_token',
client_id: clienInfo.client_id,
client_secret: clienInfo.client_secret,
refresh_token: refresh_token
}
data = JSON.stringify(data);
var opptions = {
url: "https://auth.atlassian.com/oauth/token",
method: "POST",
headers: {
'Content-Type': 'application/json'
},
body: data
};
request(opptions, function (err, res, body) {
if (err) {
console.log(err);
reject(err);
process.exit(1);
}
if (res.statusCode != 200) {
console.log(res.statusCode + " " + res.statusMessage);
process.exit(1);
}
resolve(JSON.parse(body));
});
});
return promise;
}