D
D
dark462018-10-19 19:57:09
Python
dark46, 2018-10-19 19:57:09

Why Exmo API authorization error via python requests?

In general, I am writing a client to manage my account on the EXMO exchange. The API is described
here - https://exmo.me/en/api . Reference code is also given there for receiving data via the POST method with authorization via api keys https://github.com/exmo-dev/exmo_api_lib/tree/mast... . But it does not suit me, since the http.client library does not want to work through a proxy, and in general, requests is much more convenient and works with a proxy.
Here is my code piece of code:

def call_api(api_method, **kwargs):

    params = {'nonce': int(round(time.time() * 1000))}
    if kwargs:
        params.update(kwargs)
    params = urllib.parse.urlencode(params)

    H = hmac.new(key=API_SECRET, digestmod=hashlib.sha512)
    H.update(params.encode('utf-8'))
    sign = H.hexdigest()


    headers = {"Content-type": "application/x-www-form-urlencoded",
               "Key": API_KEY,
               "Sign": sign}


    response = requests.post('https://' + API_URL + "/" + API_VERSION + "/" + api_method,
                             headers=headers,
                             params=params
                             )

I substitute the same API_KEY and API_SECRET, but through requests I get the answer:
{'result': False, 'error': 'Error 40005: Authorization error, Incorrect signature'}
Just crack it. And the reference code of norms works.
Where am I dumb?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dark46, 2018-10-19
@dark46

I figured it out myself :) I spent half a day breaking my brain, but it was necessary not params=params, but data=params :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question