LUCIT-Systems-and-Development / unicorn-binance-rest-api

A Python SDK by LUCIT to use the Binance REST API`s (com+testnet, com-margin+testnet, com-isolated_margin+testnet, com-futures+testnet, us, tr) in a simple, fast, flexible, robust and fully-featured way.
https://unicorn-binance-rest-api.docs.lucit.tech
Other
60 stars 17 forks source link

get_account() -> APIError(code=-1022): Signature for this request is not valid. #9

Closed jlixfeld closed 2 years ago

jlixfeld commented 2 years ago

I keep getting this signature exception trying to call get_account(). Am I missing something somewhere, maybe?

I tried in Postman with the same key and secret. It creates a signature and the GET is successful to {{url}}/api/v3/account?timestamp={{timestamp}}&signature={{signature}}.

Any pointers?

(binance.venv) jlixfeld@Jasons-MacBook-Pro binance % python
Python 3.8.2 (default, Jun  8 2021, 11:59:35) 
[Clang 12.0.5 (clang-1205.0.22.11)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from unicorn_binance_rest_api.unicorn_binance_rest_api_manager import BinanceRestApiManager
>>> import apikeys
>>> ubram = BinanceRestApiManager(api_key=apikeys.l_api_key, api_secret=apikeys.l_api_key)
>>> account = ubram.get_account()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/unicorn_binance_rest_api/unicorn_binance_rest_api_manager.py", line 1946, in get_account
    return self._get('account', True, data=params)
  File "/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/unicorn_binance_rest_api/unicorn_binance_rest_api_manager.py", line 339, in _get
    return self._request_api('get', path, signed, version, **kwargs)
  File "/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/unicorn_binance_rest_api/unicorn_binance_rest_api_manager.py", line 292, in _request_api
    return self._request(method, uri, signed, **kwargs)
  File "/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/unicorn_binance_rest_api/unicorn_binance_rest_api_manager.py", line 287, in _request
    return self._handle_response()
  File "/Users/jlixfeld/Documents/Development/crypto/binance/binance.venv/lib/python3.8/site-packages/unicorn_binance_rest_api/unicorn_binance_rest_api_manager.py", line 332, in _handle_response
    raise BinanceAPIException(self.response)
unicorn_binance_rest_api.unicorn_binance_rest_api_exceptions.BinanceAPIException: APIError(code=-1022): Signature for this request is not valid.
>>> 
(binance.venv) jlixfeld@Jasons-MacBook-Pro binance % pip freeze | grep -i unicorn
unicorn-binance-rest-api==1.2.0
unicorn-binance-suite==0.0.0
unicorn-binance-websocket-api==1.31.0
unicorn-fy==0.11.0
(binance.venv) jlixfeld@Jasons-MacBook-Pro binance % 
oliver-zehentleitner commented 2 years ago

Hey!

Is ubram = BinanceRestApiManager(api_key=apikeys.l_api_key, api_secret=apikeys.l_api_key) correct?

I would expect something like ubram = BinanceRestApiManager(api_key=apikeys.l_api_key, api_secret=apikeys.l_api_secret).

....

If its not that you provide key instead of secret, what about time differences?

jlixfeld commented 2 years ago

See!! I knew it was something simple!

It's funny because to test, I intentionally broke the API key and got a distinct API key error, so I assumed if the secret was incorrect, it would have produced a similar error. I guess not!

Thank you for being my second set of eyes!