Trying to login to Instagram using Instaloader,
L = ig.Instaloader()
L.login(user, password)
L.two_factor_login(11111)
raises the following error
raise TwoFactorAuthRequiredException("Login error: two-factor authentication required.")
instaloader.exceptions.TwoFactorAuthRequiredException: Login error: two-factor authentication required.
The documentation mentions that TwoFactorAuthRequiredException
is raised if the first step of 2FA login is done, and you should call Instaloader.two_factor_login()
- but because the exception is raised, in your code, that call is never reached.
Try something like:
from instaloader.exceptions import TwoFactorAuthRequiredException
L = ig.Instaloader()
try:
L.login(user, password)
except TwoFactorAuthRequiredException:
L.two_factor_login(11111)