node js oauth2 on rest api code example
Example: nodejs oauth2 request
// this saved my ass
var request = require('request');
request({
url: 'https://api.someapi.com/oauth/token',
method: 'POST',
auth: {
user: 'xxx',
pass: 'yyy'
},
form: {
'grant_type': 'client_credentials'
}
}, function(err, res) {
var json = JSON.parse(res.body);
console.log("Access Token:", json.access_token);
});