You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When attempting to log in to Instagram with an account that has Two-Factor Authentication (2FA) enabled, the instagrapi library fails to complete the login process even after the correct verification code is provided.
To Reproduce
Use the instagrapi library to attempt login with a username and password for an account that has 2FA enabled.
When prompted for the 2FA code, input the correct verification code from the authenticator app.
The login fails with the message:
"Login failed: Two-factor authentication required (you did not provide verification_code for login method)"
Expected behavior
The library should accept the provided 2FA verification code and log in successfully.
Actual Behavior
Despite entering the correct verification code, the login fails with the error mentioned above.
Example Code
Here is the relevant section of code where the login is handled:
defhandle_2fa():
"""Handle login for accounts with 2FA enabled"""globalapiusername=Prompt.ask("Enter your Instagram username")
password=Prompt.ask("Enter your Instagram password", password=True)
verification_code=Prompt.ask("[bold cyan]Enter the 2FA verification code from your authenticator app")
try:
api=Client()
# Attempt to log in using the username and passwordapi.login(username, password)
# If the login triggers 2FA, the following logic handles itifapi.two_factor_enabled():
api.two_factor_login(verification_code) # Pass the verification code explicitly# Verify successful loginconsole.print(Panel(
"[green]Login successful with 2FA verification!",
border_style="green",
box=box.ROUNDED
))
returnapiexceptExceptionase:
console.print(Panel(
f"[red]Login failed: {str(e)}",
border_style="red",
box=box.ROUNDED
))
returnNone
Desktop (please complete the following information):
OS: Windows 10.0.22631
Python version: 3.12.4
instagrapi version: instagrapi 2.1.3
moveipy version: moveipy not installed or command not found
imagemagick version: convert version check failed
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
Try Instagrapi SaaS with a free trial https://hikerapi.com/p/5GBWznd3
Describe the bug
When attempting to log in to Instagram with an account that has Two-Factor Authentication (2FA) enabled, the
instagrapi
library fails to complete the login process even after the correct verification code is provided.To Reproduce
instagrapi
library to attempt login with a username and password for an account that has 2FA enabled."Login failed: Two-factor authentication required (you did not provide verification_code for login method)"
Expected behavior
The library should accept the provided 2FA verification code and log in successfully.
Actual Behavior
Despite entering the correct verification code, the login fails with the error mentioned above.
Example Code
Here is the relevant section of code where the login is handled:
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: