Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

binance exchange: 403 responses (dev branch) #194

Open
firepol opened this issue May 28, 2018 · 1 comment
Open

binance exchange: 403 responses (dev branch) #194

firepol opened this issue May 28, 2018 · 1 comment

Comments

@firepol
Copy link

firepol commented May 28, 2018

Hi,

can somebody please test the binance exchange api on the dev branch?

Public endpoints (ticker etc. work) but as soon as I try something related to my account I get 403 responses.

E.g. try the wallet method. I think the problem is related on how the request is signed.
I tried my api key/secret using a different library (python-binance) and on that one it works perfectly.

I compared how request signing is done on python-binance and on bitex and they are slightly different (check in particular params in kwargs).

I'll investigate this further but I'd like somebody else to do a quick test and confirm it's a reproducible bug and not just on my side... just to be sure. THX

To test, try:

api = bitex.Binance('apiKey', 'apiSecret')
wallet = api.wallet().json()
print(wallet)
firepol added a commit to firepol/bitex that referenced this issue May 28, 2018
firepol added a commit to firepol/bitex that referenced this issue May 28, 2018
@firepol
Copy link
Author

firepol commented May 28, 2018

There were several issues. The hardest to find was the one generated by this call:

req_kwargs = super(BinanceREST, self).sign_request_kwargs(endpoint, **kwargs)

    def sign_request_kwargs(self, endpoint, **kwargs):
        """
        Generate dummy Request Kwarg Signature.

        Extend this to implement signing of requests for private API calls. By default, it supplies
        a default URL using generate_uri and generate_url.

        :param endpoint: str, API Endpoint
        :param kwargs: Kwargs meant for requests.Request()
        :return: dict, request kwargs
        """
        uri = self.generate_uri(endpoint)
        url = self.generate_url(uri)
        template = {'url': url, 'headers': {}, 'files': {},
                    'data': {}, 'params': {}, 'auth': {}, 'cookies': {},
                    'hooks': {}, 'json': {}}
        template.update(kwargs)
        return template

The template returned had many empty dictionaries, one or all of them were causing the 403 errors.

Also the req_string for the GET calls was not including all the parameters.

See my PR. I tested basically all the methods, even did an bid request and cancel order. Everything works for me.

firepol added a commit to firepol/bitex that referenced this issue May 29, 2018
firepol added a commit to firepol/bitex that referenced this issue May 29, 2018
firepol added a commit to firepol/bitex that referenced this issue May 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant