delta-exchange / python-rest-client

https://pypi.org/project/delta-rest-client/
13 stars 19 forks source link

HTTPError: 401 Client Error: Unauthorized for url: https://testnet-api.delta.exchange/v2/positions?product_id=27 #46

Open akumar1503 opened 4 months ago

akumar1503 commented 4 months ago

I'm getting below error on using python client, I've already whitelisted my ip (from http://whatismyipaddress.com) and used the api keys as mentioned on readme.

Below is the call being made and error I'm getting, in client I can already see auth=True is passed.

delta_client.get_position(27)

Traceback (most recent call last): File "", line 1, in File "/venv_p3/lib/python3.11/site-packages/delta_rest_client/delta_rest_client.py", line 138, in get_position response = self.request( ^^^^^^^^^^^^^ File "/venv_p3/lib/python3.11/site-packages/delta_rest_client/delta_rest_client.py", line 68, in request res.raise_for_status() File "/venv_p3/lib/python3.11/site-packages/requests/models.py", line 943, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://testnet-api.delta.exchange/v2/positions?product_id=27

akumar1503 commented 3 months ago

Discussed with PM, a work around: Whitelisting IPv6 address worked for me.

18patti commented 1 month ago

Hi I whitelisted my ipv4 address but still the error is throwing. I checked the api key and secret are valid as well.

line 21, in order_response = delta_client.place_order( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\delta_rest_client\delta_rest_client.py", line 234, in place_order return self.create_order(order) ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\delta_rest_client\delta_rest_client.py", line 91, in create_order response = self.request('POST', "/v2/orders", order, auth=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\delta_rest_client\delta_rest_client.py", line 68, in request res.raise_for_status() File "C:\Python312\Lib\site-packages\requests\models.py", line 1024, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.delta.exchange/v2/orders

Thanks

Chap92 commented 1 month ago

Hi I whitelisted my ipv4 address but still the error is throwing. I checked the api key and secret are valid as well.

line 21, in order_response = delta_client.place_order( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\delta_rest_client\delta_rest_client.py", line 234, in place_order return self.create_order(order) ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\delta_rest_client\delta_rest_client.py", line 91, in create_order response = self.request('POST', "/v2/orders", order, auth=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\delta_rest_client\delta_rest_client.py", line 68, in request res.raise_for_status() File "C:\Python312\Lib\site-packages\requests\models.py", line 1024, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.delta.exchange/v2/orders

Thanks

You need to add both IPV6 and IPV4 addresses, in that order (IPV6 address,IPV4 address)