I am trying to consume Lazada API through HTTP requests in NodeJS and it requires a signature as one of the parameters.
To generate that, I'm using the js-256 package but for some reason I'm getting an IncompleSignature
error.
The exact error message:
{ type: 'ISV',
code: 'IncompleteSignature',
message: 'The request signature does not conform to lazada standards',
request_id: '0be6e79215428302067761224' }
My code:
var sha256 = require('js-sha256');
module.exports = function(app, Request){
app.get('/', function(req,res){
var access_token = "myToken";
var app_key = "myAppKey";
var order_id = "36835322434";
var sign_method = "sha256";
var timestamp = new Date().timestamp;
var concatenatedString = "/order/items/getaccess_token"+access_token
+"app_key"+app_key
+"order_id"+order_id
+"sign_method"+sign_method
+"timestamp"+new Date().getTime();
var hash = sha256.hmac.create("myAppSecret");
hash.update(concatenatedString);
var httpRequestLink = "http://api.lazada.co.th/rest/order/items/get?access_token="+access_token
+"&app_key="+app_key
+"&order_id="+order_id
+"&sign_method="+sign_method
+"×tamp="+new Date().getTime()
+"&sign="+hash.hex();
Request.get(httpRequestLink, (error, response, body) => {
if(error) {
return console.log(error);
}
console.log(JSON.parse(body));
});
});
}
Would really appreciate if someone can help me out here. Thanks