I am using the code below to retrieve a refresh_token. When I run it, I get the token in the console but if I want to return something instead, I get nothing. Basically I cannot use this code to generate a token that can then be use in another piece of code. What am I missing?
var request = require("request");
var options = {
method: 'POST',
url: 'https://YOUR_DOMAIN/oauth/token',
headers: {'content-type': 'application/x-www-form-urlencoded'},
form: {
grant_type: 'refresh_token',
client_id: 'YOUR_CLIENT_ID',
client_secret: 'YOUR_CLIENT_SECRET',
refresh_token: 'YOUR_REFRESH_TOKEN'
}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});