Help me log in to the api poloniex. Below is written my code with which I am trying to log in, but it gives me an error! Python version 3.5. Help me please understand what I'm doing wrong!
import urllib
import requests
import json
import time
import hmac,hashlib
api_secret ="111111111111111111111111111111111111111111111111111111111"
api_key="YYYYYYYY-IIIIIIII-PPPPPPPP-LLLLLLLL"
nonce = int(time.time() * 1000)
parms = {"nonce": nonce,"command":'returnBalances'}
post_data = urllib.parse.urlencode(parms)
sign = hmac.new( api_secret.encode(),post_data.encode(), hashlib.sha512).hexdigest()
print(sign)
headers = {"Sign":sign,"Key":api_key}
public = requests.post('https://poloniex.com/tradingApi',post_data,headers)
print(public.text)
The result of the program is the following: {"error":"Invalid API key/secret pair."}