stanvanrooy / instauto

Simple to use wrapper around the private Instagram API, written in Python.
https://instauto.readthedocs.io
MIT License
103 stars 24 forks source link

Error while using proxy #135

Closed ItsFlorkast closed 3 years ago

ItsFlorkast commented 3 years ago

Describe the bug Hello, I have been trying to use proxy to post on instagram. However, I faced this error File "C:\Users\Administrator\Desktop\e\s.py", line 49, in PostToInsta client.login() File "C:\Program Files\Python37\lib\site-packages\instauto\api\actions\authentication.py", line 40, in login self._update_token() File "C:\Program Files\Python37\lib\site-packages\instauto\api\actions\authentication.py", line 152, in _update_token default_headers=False) File "C:\Program Files\Python37\lib\site-packages\instauto\api\actions\request.py", line 221, in _request raise e File "C:\Program Files\Python37\lib\site-packages\instauto\api\actions\request.py", line 212, in _request resp = self._session.get(url, headers=headers) File "C:\Program Files\Python37\lib\site-packages\requests\sessions.py", line 555, in get return self.request('GET', url, **kwargs) File "C:\Program Files\Python37\lib\site-packages\requests\sessions.py", line 542, in request resp = self.send(prep, **send_kwargs) File "C:\Program Files\Python37\lib\site-packages\requests\sessions.py", line 655, in send r = adapter.send(request, **kwargs) File "C:\Program Files\Python37\lib\site-packages\requests\adapters.py", line 514, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='i.instagram.com', port=443): Max retries exceeded with url: /api/v1/zr/token/result/?device_id=android-eced435a882c37a3&token_hash=&custom_device_id=0f24ee50-eced-435a-882c-37a36299929b&fetch_reason=token_expired (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1091)'))) maybe because instauto does not support proxy? Also my ssl version OpenSSL 1.1.1g 21 Apr 2020

stanvanrooy commented 3 years ago

Looks like an issue unrelated to Instauto. Instauto just sends a request, it currently does nothing with proxies.

If you want ot use a proxy, you should set it system/sandbox wide. Instagram will use the os's connection.

ItsFlorkast commented 3 years ago

Looks like an issue unrelated to Instauto. Instauto just sends a request, it currently does nothing with proxies.

If you want ot use a proxy, you should set it system/sandbox wide. Instagram will use the os's connection.

thats weird, because I set it in my system but still facing this problem :/

ItsFlorkast commented 3 years ago

Update: still having the issue and contacted with proxy provider and he replies by that “ Hi,

The error "SSL_WRONG_VERSION_NUMBER" is an error from your code (python maybe), please check your bot software settings and documentation.

You can check our proxies using the curl command or using a browser.” Also, I tried the example code of posting a picture without changing anything and still having the same issue. I’ll try to check the login function of instauto.

stanvanrooy commented 3 years ago

The only thing instauto does, is send a request, using the requests library. Nothing more and nothing less.

It doesn't interact with your proxy.

ItsFlorkast commented 3 years ago

The only thing instauto does, is send a request, using the requests library. Nothing more and nothing less.

It doesn't interact with your proxy.

Hi, Thanks for replying. Actually I’m using requests library and I had the same issue I guess and solved it by adding proxy parameter and typing my proxy. So maybe I have to modify the requests inside instauto.

ItsFlorkast commented 3 years ago

Hi, Since yesterday and I was trying. so here some updates, I modified the code of requesting and make it works with proxy. However, the first run it require a verification code when I enter it I got this error Received a non-200 response from Instagram. the second run I got only the error above without requiring verification code ;-; do you think it is because of proxy? idk because I bought two proxies from different providers and still having the same issue :( Also, I checked whether the proxy works with HTTPS and it works really.

the things I changed is very small which in the request.py file Before

**Method.POST**
 resp = self._session.post(url, data, headers=headers)
**Method.GET**
resp = self._session.get(url, headers=headers)

After

proxies = { 
              "http"  : "http://user:password@ip:port", 
              "https" : "http://user:password@ip:port"
            }
 **Method.POST**
resp = self._session.post(url, data, headers=headers,proxies=proxies)
** Method.GET**
resp = self._session.post(url, headers=headers,proxies=proxies)

I hope those information are helpful. I'll try again tomorrow.

yeah also to get verification code again you have to delete instauto save file.

bye ;-;

ItsFlorkast commented 3 years ago

Hi, still trying to know whats wrong but I ended up knowing nothing :(

the error I got


Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\file\www.py", line 15, in <module>
    client.login()
  File "C:\Program Files\Python39\lib\site-packages\instauto\api\actions\authentication.py", line 64, in login
    resp = self._request('accounts/login/', Method.POST, data=data2, signed=True)
  File "C:\Program Files\Python39\lib\site-packages\instauto\api\actions\request.py", line 238, in _request
    self._check_response_for_errors(resp)
  File "C:\Program Files\Python39\lib\site-packages\instauto\api\actions\request.py", line 279, in _check_response_for_errors
    raise BadResponse("Received a non-200 response from Instagram")
instauto.api.exceptions.BadResponse: Received a non-200 response from Instagram

I hope you can help me.

ItsFlorkast commented 3 years ago

Hi, Fixed by using a proxy that supports https.