1

I am using this code to write a bottrader,in python3 (converted 2to3) https://pastebin.com/fbkheaRb

except that i have change secret string and post_data string to byte

sign = hmac.new(self.Secret.encode("ASCII"), post_data.encode("ASCII"), hashlib.sha512).hexdigest()

but getting below error

urllib.error.HTTPError: HTTP Error 403: Forbidden

have checked key and secret key multiple time and it is correct Also deleted the existing key and created new Also relaxed all IP

then also got the same problem, please help

Muhammad Saad
  • 713
  • 1
  • 9
  • 31
Abhishek
  • 519
  • 1
  • 6
  • 24
  • You could use the [`poloniex`](https://pypi.python.org/pypi/poloniex) package which supports Python 3. Then you don't have to deal with the request authentication details. – mhawke Nov 26 '17 at 10:25
  • trade = poloniex.Poloniex(apiKey,secretKey); market_data = trade.returnTicker()["BTC_ETH"]; print(market_data["highestBid"]); this give me an error json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) – Abhishek Nov 26 '17 at 11:07
  • I debugged the code and saw that it returned an html which asks for captcha before it failed. ideally when i have given api, secret key it should not ask for captcha isn't it? – Abhishek Nov 26 '17 at 11:19
  • 1
    any pointers will be really helpful, I really need do this? is there any other workaround. – Abhishek Nov 27 '17 at 16:21

1 Answers1

1

You don't need to encode to ASCII, so you may try:

sign = hmac.new(self.Secret, post_data, hashlib.sha512).hexdigest()
A. STEFANI
  • 6,707
  • 1
  • 23
  • 48
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/low-quality-posts/19197848) – Athena Mar 22 '18 at 19:33
  • Why do you consider my answer as a clarification or a critique, do you double check if I am right or wrong before leaving this comment ? it maybe the solution... – A. STEFANI Mar 22 '18 at 21:00
  • @A STEFANI- it isn't about the correctness of the solution; answers should provide a complete and clear explanation of the code; what you have here is pretty much a code only answer with little explanation. Editing it to explain it a bit better would help. – Athena Mar 23 '18 at 02:13