ping / instagram_private_api

A Python library to access Instagram's private API.
MIT License
2.95k stars 612 forks source link

current_user 405 error #312

Open axel7083 opened 3 years ago

axel7083 commented 3 years ago

Which client are you using?

Describe the Bug/Error:

Simply calling the current_user method leads to a 405 error, the endpoint probably changed.


Paste the output of python -V here: Python 2.7.17

Code:

from instagram_private_api import Client, ClientCompatPatch
user_name = 'username'
password = 'password'

api = Client(user_name, password)
api.current_user()

Error/Debug Log:

---------------------------------------------------------------------------
ClientConnectionError                     Traceback (most recent call last)
<ipython-input-14-47a9f5747eaf> in <module>()
----> 1 api.current_user()

C:\Users\axels\MiniConda3\envs\py27\lib\site-packages\instagram_private_api\endpoints\accounts.pyc in current_user(self)
     77         """Get current user info"""
     78         params = self.authenticated_params
---> 79         res = self._call_api('accounts/current_user/', params=params, query={'edit': 'true'})
     80         if self.auto_patch:
     81             ClientCompatPatch.user(res['user'], drop_incompat_keys=self.drop_incompat_keys)

C:\Users\axels\MiniConda3\envs\py27\lib\site-packages\instagram_private_api\client.pyc in _call_api(self, endpoint, params, query, return_response, unsigned, version)
    532                 ConnectionError) as connection_error:
    533             raise ClientConnectionError('{} {}'.format(
--> 534                 connection_error.__class__.__name__, str(connection_error)))
    535 
    536         if return_response:

ClientConnectionError: URLError <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it>
llamaXc commented 3 years ago

Ditto, I to an getting the same error. Ive tried with python2.7 and python3. Using the private app api.

` File "C:\Users\Preston Meade\AppData\Local\Programs\Python\Python38\lib\site-packages\instagram_private_api\client.py", line 523, in _call_api response = self.opener.open(req, timeout=self.timeout) File "C:\Users\Preston Meade\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 531, in open response = meth(req, response) File "C:\Users\Preston Meade\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 640, in http_response response = self.parent.error( File "C:\Users\Preston Meade\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 569, in error return self._call_chain(args) File "C:\Users\Preston Meade\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 502, in _call_chain result = func(args) File "C:\Users\Preston Meade\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 649, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 405: Method Not Allowed

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "main.py", line 108, in user = api.current_user()['user'] File "C:\Users\Preston Meade\AppData\Local\Programs\Python\Python38\lib\site-packages\instagram_private_api\endpoints\accounts.py", line 79, in current_user res = self._call_api('accounts/current_user/', params=params, query={'edit': 'true'}) File "C:\Users\Preston Meade\AppData\Local\Programs\Python\Python38\lib\site-packages\instagram_private_api\client.py", line 527, in _call_api ErrorHandler.process(e, error_response) File "C:\Users\Preston Meade\AppData\Local\Programs\Python\Python38\lib\site-packages\instagram_private_api\errors.py", line 141, in process raise ClientError(error_msg, http_error.code, error_response) instagram_private_api.errors.ClientError: Method Not Allowed `

reneilpascua commented 3 years ago

i get the same as above. would like to just pull information from the current_user

YusufBerki commented 2 years ago

This error caused by sending a request to the current_user endpoint with the POST method. The current_user endpoint only supports the GET method.

You can fix this issue with #379