Closed oitozero closed 10 years ago
The issue was with reading the private key.
var Xero = require('xero');
var CONSUMER_KEY = '...';
var CONSUMER_SECRET = '...';
var RSA_PRIVATE_KEY = require('fs').readFileSync('privatekey.pem');
var xero = new Xero(CONSUMER_KEY, CONSUMER_SECRET, RSA_PRIVATE_KEY);
xero.call('GET', '/Users', null, function(err, json) {
if (err) {
console.error(err);
}
console.log('response:' + JSON.stringify(json));
});
I tried with
var RSA_PRIVATE_KEY = require('fs').readFileSync('privatekey.pem');
var xero = new Xero(CONSUMER_KEY, CONSUMER_SECRET, RSA_PRIVATE_KEY);
and also tried with passing .pem key as a RSA_PRIVATE_KEY
but still facing
{ statusCode: 401, data: 'oauth_problem=signature_invalid&oauth_problem_advice=Failed%20to%20validate%20signature' }
Getting an OAuth error when trying to run the request example.
Here are my steps:
Created a Xero Private application. Generated public/private certs using:
Uploaded public key certificate (publickey.cer). Obtained consumer key/secret. Tested sample https://github.com/thallium205/xero#request. Getting following error:
What am I missing here?
Thanks.