1
I'm having trouble following LakeBTC's API instructions for connecting to their API via Python.
API Documentation: https://www.lakebtc.com/s/api
I have my key (email address) and secret. I'm using the API URL: https://www.LakeBTC.com/api_v1
No matter what I try, I get a 401 Error. Below is my code, any ideas?
tonce = str(int(time.time() * 1e6))
p = 'tonce=' + tonce \
+ '&accesskey=' + self.key \
+ '&requestmethod=post' \
+ '&id=1' \
+ '&method=' + 'getAccountInfo' \
+ '¶ms='
# Create signature
hmac_obj = hmac.new(self.secret, p, hashlib.sha1)
b64 = 'Basic ' + base64.b64encode(self.key + ':' + hmac_obj.digest())
header = {
'Json-Rpc-Tonce': tonce,
'Authorization': b64,
'content-type': 'application/json-rpc',
}
response = requests.post(self.apiUrl, data=p, headers=header)
Am I encrypting and hashing correctly?
What does the returned WWW-Authenticate header say? Is there a body to the response? If so, does it show an error? – Nick ODell – 2014-10-23T05:55:09.383
No body is returned, here is the returned header: {'status': '401 Unauthorized', 'x-request-id': '94f303be4a3e97e8dc289fbe1881555b', 'x-powered-by': 'Phusion Passenger 4.0.14', 'transfer-encoding': 'chunked', 'x-runtime': '0.002153', 'server': 'nginx/1.6.0', 'connection': 'keep-alive', 'x-ua-compatible': 'IE=Edge,chrome=1', 'cache-control': 'no-cache', 'date': 'Thu, 23 Oct 2014 17:18:16 GMT', 'content-type': 'application/json; charset=utf-8', 'x-rack-cache': 'invalidate, pass'} – quannabe – 2014-10-23T17:25:50.900