ping / instagram_private_api

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

Logging in requires OTP #240

Open sharunkumar opened 4 years ago

sharunkumar commented 4 years ago

Please follow the guide below


Before submitting an issue, make sure you have:

Which client are you using?


Describe the Bug/Error:

Please make sure the description is worded well enough to be understood with as much context and examples as possible.

I tried using this api but I am not able to log in (error log attached) plus I am getting an OTP on my mobile number registered with instagram.

Code to replicate the error must be provided below.

from instagram_private_api import Client, ClientCompatPatch

user_name = '[redacted]'
password = '[redacted]'

api = Client(user_name, password)

Paste the output of python -V here:

Code:

# Example code that will produce the error reported
from instagram_web_api import Client

web_api = Client()
user_feed_info = web_api.user_feed('1234567890', count=10)

Error/Debug Log:

> Executing task: python app\main.py <

Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\instagram_private_api\client.py", line 523, in _call_api
    response = self.opener.open(req, timeout=self.timeout)
  File "C:\Python37\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "C:\Python37\lib\urllib\request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Python37\lib\urllib\request.py", line 569, in error
    return self._call_chain(*args)
  File "C:\Python37\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)
  File "C:\Python37\lib\urllib\request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "app\main.py", line 6, in <module>
    api = Client(user_name, password)
  File "C:\Python37\lib\site-packages\instagram_private_api\client.py", line 208, in __init__
    self.login()
  File "C:\Python37\lib\site-packages\instagram_private_api\endpoints\accounts.py", line 50, in login
    'accounts/login/', params=login_params, return_response=True)
  File "C:\Python37\lib\site-packages\instagram_private_api\client.py", line 527, in _call_api
    ErrorHandler.process(e, error_response)
  File "C:\Python37\lib\site-packages\instagram_private_api\errors.py", line 135, in process
    raise ClientError(error_msg, http_error.code, error_response)
instagram_private_api.errors.ClientError: Bad Request
The terminal process terminated with exit code: 1
Mishul-G commented 4 years ago

Hey @sharunkumar were you able to get this working? Is this thread dead?

sharunkumar commented 4 years ago

@Mishul-G hope haven't found a way to make this work. I guess this is because I have TFA enabled on my account 🤔 maybe turning it off would make it work

Mishul-G commented 4 years ago

Yeah that’s worth a try. Are any other aspects of api working that you have tried?

sharunkumar commented 4 years ago

I just played around with the api many months ago and it seemed to be working fine. but this TFA problem is new to me

autoiue commented 4 years ago

There is a fork that provides 2FA methods here : https://github.com/pbotsman/instagram_private_api