let endPoint = 'https://hostname/services/oauth2/token';
let requestBody = {
'client_id': { client_id },
'client_secret': { client_secret },
'username': { username },
'password': { password },
'grant_type': 'password'
};
let salesRequest = https.post({
url: endPoint,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: Object.keys(requestBody).map(key => key + '=' + encodeURIComponent(requestBody[key])).join('&')
});
let responseBody = JSON.parse(salesRequest.body);