Open diptenagile opened 8 years ago
+1
The below setup is working for me... could it be that you need to use ./privatekey.pem
or './cert/privatekey.pem' --- so ./
before your file name ?
var Xero = require('xero');
var CONSUMER_KEY = 'SOME_KEY';
var CONSUMER_SECRET = 'SOME_SECRET';
var RSA_PRIVATE_KEY = require('fs').readFileSync('./cert/privatekey.pem');
var xero = new Xero(CONSUMER_KEY, CONSUMER_SECRET, RSA_PRIVATE_KEY);
xero.call('GET', '/Users', null, function(err, json) {
if (err) {
return console.log('Error', err);
}
return console.log('json', json);
});
@FreakDroid if I understand your question correctly.
Look into one of these links:
Mac: https://rietta.com/blog/2012/01/27/openssl-generating-rsa-key-from-command/
PC: https://support.rackspace.com/how-to/generating-rsa-keys-with-ssh-puttygen/
Also consider the security perspective.
@benbowes Hi again, thanks for you help.
But now I have another question, after you create the public and private key, How do you upload the publickey in the Xero's server for the autentication??? Because If I understand good, that is necesary for Xero to autenticate you, or I'm complete misunderstand the docs.
Thanks.
Hi @FreakDroid
You need to upload your certificate or should I say contents of the certificate.
I placed mine in a folder called cert
at the root of the directory and I added the files also to my .gitignore
file :)
I generated private/public key pair using:
and create private app using publickey.cer file and pass private key in configuration :
I also tried to to pass RSA_PRIVATE_KEY directly in xero config. But still i facing
{ statusCode: 401, data: 'oauth_problem=signature_invalid&oauth_problem_advice=Failed%20to%20validate%20signature' }
Please help me. Thanks.