Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

current_user 405 error #312

Open
1 of 2 tasks
axel7083 opened this issue Nov 9, 2020 · 3 comments
Open
1 of 2 tasks

current_user 405 error #312

axel7083 opened this issue Nov 9, 2020 · 3 comments

Comments

@axel7083
Copy link

axel7083 commented Nov 9, 2020

Which client are you using?

  • app (instagram_private_api/)
  • web (instagram_web_api/)

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
Copy link

llamaXc commented Nov 20, 2020

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
Copy link

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

YusufBerki added a commit to YusufBerki/instagram_private_api that referenced this issue Mar 5, 2022
@YusufBerki
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants