使用API​​无法获得HMAC身份validation

我试图使用HMAC与LocalBitcoins API进行身份validation。

这是用Python编写的authentication:

message = str(nonce) + hmac_auth_key + relative_path + get_or_post_params_urlencoded signature = hmac.new(hmac_auth_secret, msg=message, digestmod=hashlib.sha256).hexdigest().upper() 

以及创buildHMAC消息的参数:

 Nonce. A 63 bit positive integer, for example unix timestamp as milliseconds. HMAC authentication key. This is the first one of a key/secret pair. Relative path, for example /api/wallet/. GET or POST parameters in their URL encoded format, for example foo=bar&baz=quux. 

以下是我如何构buildHMAC:

 var milliseconds = (new Date).getTime(); var key = config.key; var secret = config.secret; var nonce = milliseconds.toString() var message = nonce + key + 'api/myself'; var hmac_digest = crypto.createHmac("sha256", secret).update(message).digest('hex').toUpperCase(); 

签名通过3个HTTP头发送。 调用api / myself方法的选项如下所示(使用请求):

 { url: 'https://localbitcoins.com/api/myself', method: 'GET', headers: { 'Apiauth-Key': 'my api key', 'Apiauth-Nonce': 1439925212276, 'Apiauth-Signature': 'the created signature' }, timeout: 5000 } 

并要求:

 var req = request.get(options, function(error, response, body) { console.log(body); }); 

但每次我得到以下错误信息:

 { error: { message: 'HMAC authentication key and signature was given, but they are invalid.', error_code: 41 } } 

我已经在testing中尝试了很多不同的组合,但不能得到任何工作。 我错过了什么?

事实certificate,我的路是错的。

/path需要/path/ ,我发现通过与一个工作的Python实现工作。

现在这个包已经启动并运行了: https : //github.com/mrmayfield/localbitcoins-node

我认为(new Date).getTime(); 不是创build一个63位整数。 每Axel博士的职位 。 JavaScript有53位整数加上一个符号。