Open mateusangelo opened 1 year ago
I also get the same message "Bad Password" when I try to login.
{
"detail": "The password you entered is incorrect. Please try again. If you are sure that the password is correct, then change your IP address, because it is added to the blacklist of the Instagram Server",
"exc_type": "BadPassword"
}
I thought that may be Instagram really blocked my IP, but then tried proxy, then tried on another machine with another IP and the result is the same. Currently I am using instagrapi-rest with latest instagrapi@2.0.0. Tried to downgrade to 1.18.5, but the problem remains the same.
I have the exact same problem, did you find out what was the problem?
Try Instagrapi SaaS with a free trial https://hikerapi.com/p/5GBWznd3
No Describe the bug I tried with 3 diferentes IP locations, but it dont connect to instagram anymore. To Reproduce import sys
import os.path from pathlib import Path from instagrapi import Client from instagrapi.types import StoryMedia from instagrapi.story import StoryBuilder from instagrapi.types import StoryMention, StoryMedia, StoryLink, StoryHashtag import re import random import email import imaplib
from instagrapi.mixins.challenge import ChallengeChoice
CHALLENGE_EMAIL = "emai@mail.com" CHALLENGE_PASSWORD = "pass"
IG_USERNAME = "account" IG_PASSWORD = "pass"
IG_CREDENTIAL_PATH = "/settings.json"
def get_code_from_email(username): mail = imaplib.IMAP4_SSL("imap.hostinger.com") mail.login(CHALLENGE_EMAIL, CHALLENGE_PASSWORD,relogin=True) mail.select("inbox") result, data = mail.search(None, "(UNSEEN)") assert result == "OK", "Error1 during get_code_from_email: %s" % result ids = data.pop().split() for num in reversed(ids): mail.store(num, "+FLAGS", "\Seen") # mark as read result, data = mail.fetch(num, "(RFC822)") assert result == "OK", "Error2 during get_code_from_email: %s" % result msg = email.message_from_string(data[0][1].decode()) payloads = msg.get_payload() if not isinstance(payloads, list): payloads = [msg] code = None for payload in payloads: body = payload.get_payload(decode=True).decode() if "<div" not in body: continue match = re.search(">([^>]?({u})[^<]?)<".format(u=username), body) if not match: continue print("Match from email:", match.group(1)) match = re.search(r">(\d{6})<", body) if not match: print('Skip this email, "code" not found') continue code = match.group(1) if code: return code return False
def get_code_from_sms(username): while True: code = input(f"Enter code (6 digits) for {username}: ").strip() if code and code.isdigit(): return code return None
def challenge_code_handler(username, choice): if choice == ChallengeChoice.SMS: return get_code_from_sms(username) elif choice == ChallengeChoice.EMAIL: return get_code_from_email(username) return False
def change_password_handler(username):
Simple way to generate a random string
if name == "main": cl = Client() cl.challenge_code_handler = challenge_code_handler if os.path.exists(IG_CREDENTIAL_PATH): cl.load_settings(IG_CREDENTIAL_PATH) cl.login(IG_USERNAME, IG_PASSWORD, relogin=True) else: cl.login(IG_USERNAME, IG_PASSWORD, relogin=True) cl.dump_settings(IG_CREDENTIAL_PATH)
Traceback Show your full traceback so that it is clear where exactly the error occurred.
Exception has occurred: BadPassword The password you entered is incorrect. Please try again. If you are sure that the password is correct, then change your IP address, because it is added to the blacklist of the Instagram Server requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://i.instagram.com/api/v1/accounts/login/
During handling of the above exception, another exception occurred:
File "/Users/mateusdepaula/Projects/DDMBot/PromoBffBot/bin/data/script2.py", line 89, in
cl.login(IG_USERNAME, IG_PASSWORD, relogin=True)
instagrapi.exceptions.BadPassword: The password you entered is incorrect. Please try again. If you are sure that the password is correct, then change your IP address, because it is added to the blacklist of the Instagram Server
Expected behavior Connect to instagram account
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context it fails on cl.login(IG_USERNAME, IG_PASSWORD, relogin=True)