Closed Jakobud closed 7 years ago
I have a particular REST api I can connect to with the following code:
const options = { body: 'grant_type=client_credentials', auth: id + ':' + password, json: true, headers: { 'Content-Type': 'application/x-www-form-urlencoded' } } https.request(endpointUrl, options, function(res) { // do something with res })
How do I make this same connection using node-rest-client?
node-rest-client
I tried this and a few variations but didn't get anywhere. Server is telling me invalid client so the formatting is definitely not right.
let args = { data: { grant_type: 'client_credentials' }, headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, // user: id, // password: pass, // also tried user and pass separate but no dice. auth: id + ':' + pass, json: true } client.post(accessTokenEndpoint, args, (data, res) => { console.log(data) })
any clues?
I figured it out. I was not passing id and pass into the client. That fixed it. Thanks
I have a particular REST api I can connect to with the following code:
How do I make this same connection using
node-rest-client
?I tried this and a few variations but didn't get anywhere. Server is telling me invalid client so the formatting is definitely not right.
any clues?