Ok so i'm going crazy trying to write a python3 code to get to gox's api v1
i found few programs but they either didn't work for me or are still doing v0 api. After taking all of the stuff out it came down that even the basic test case fails. Can someone please point out what i'm doing wrong here?
when i execute the following code i get
e.code -> 403
e.read -> b'{"result":"error","error":"Identification required to access private API","token":"login_error_invalid_rest_key"}'
(API keys are correct and are enabled on gox)
import time
import urllib.parse
import urllib.request
import base64
import hmac
import hashlib
url = "https://data.mtgox.com/api/1/generic/info"
GOX_secret = "your secret here"
GOX_secret = base64.b64decode((GOX_secret.encode()))
GOX_key = "your keyname here"
params = {"nonce":str(int(time.time()*1000))}
post_data = urllib.parse.urlencode(params)
#ahmac = base64.b64encode(str(hmac.new(base64.b64decode(self.secret),post_data,hashlib.sha512).digest()))
H = hmac.new(GOX_secret, post_data.encode(), hashlib.sha512).digest()
sign = base64.b64encode(H)
header = {"User-Agent": 'myGoxAPI', "Rest-Key": GOX_key, "Rest-Sign": sign}
req = urllib.request.Request(url, post_data, header) #POST
try:
response = urllib.request.urlopen(req, post_data.encode()) #POST
except urllib.error.HTTPError as e:
print("e.code ->", e.code)
print("e.read ->", (e.read()))
exit(5)
print("It'd be nice to get here")