Sunday 14 January 2018

What i am doing wrong here(requesting private API)

Ok, this is what docs say: http://ift.tt/2D0utWR code:let request = require('request'), crypto = require('crypto'), URI = "http://ift.tt/2DxFOz7", API_PUBLIC_KEY = "", //my api here POST_PARAMS = new Buffer("BTC").toString('base64'), NONCE = 4465456, SIGNATURE = API_PUBLIC_KEY + "POST" + URI + NONCE + POST_PARAMS, url = "http://ift.tt/2DxFOz7", auth = 'Basic ' + encrypt("", API_PUBLIC_KEY + ":" + SIGNATURE + ":" + NONCE); //my secret here in 1st parameter slot function encrypt(key, str) { var hmac = crypto.createHmac("sha512", key); var signed = hmac.update(new Buffer(str, 'utf-8')).digest('base64'); return signed } request.post( { url : url, headers : { "Authorization" : auth } }, function (error, response, body) { console.log(body); } );

Submitted January 14, 2018 at 08:44AM by dedaloodak

No comments:

Post a Comment