On another note, has anyone ever validated an oAut...
# suitescript
m
On another note, has anyone ever validated an oAuth request to NetSuite in a Node.js script? I tried writing a nice function to do it and it was not working at all, so I made a simple static script to see if it could even be done. I followed a working PHP example from elsewhere in the company. It spits out the exact same format as far as I can tell, but no matter what I get invalid signature. I must be something massively stupid but I am blind to it:
b
I vote letting another package do it for you
Copy code
var account = '';
var oauth = {
  consumer_key: '',
  consumer_secret: '',
  token: '',
  token_secret: '',
  realm: account
};
var request = require('request-promise');

request('<https://rest.netsuite.com/rest/datacenterurls>', {
  qs: { account: account },
  json: true
})
  .then(function(response) {
    return request(response.restDomain + '/app/site/hosting/restlet.nl', {
      qs: { script: '', deploy: '' },
      oauth: oauth,
      json: true
    }).then(function(response) {
      console.log(response);
    });
  })
  .catch(function(e) {
    console.error(e);
  });
💯 3
m
oauth is build into request-promise? I didn't realize that.
b
m
On the plus side that worked. On the down side I have wasted hours of my life.
Thank you so much though.
c
you didn't totally waste.. you learned something which is always a plus
m
True. I also learned a lot about how oAuth works. Which will be valuable the next time it invariably breaks.
c
exactly! not a waste
b
taking a look at your code, you were hardcore enough to try to set the content-length. If you didn't want to use request, I would have recommend you look at https://www.npmjs.com/package/oauth-1.0a.