fbchat: Login failed

I tried this and if i put right credentials it always write that i have wrong password Used example echo bot

Environment information

  • Python version - 3.7.3
  • fbchat version - that one from pip install fbchat Package Version

aenum 2.1.2 attrs 18.2.0 beautifulsoup4 4.7.1 certifi 2019.6.16 chardet 3.0.4 fbchat 1.7.0 idna 2.8 pip 19.1.1 requests 2.22.0 setuptools 40.8.0 soupsieve 1.9.2 urllib3 1.25.3

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 29 (5 by maintainers)

Most upvoted comments

“/gettingstarted” is the url for a page with some intructions for setting up your account (like adding contacts or a mobile number), it only appears on new accounts so it goes away after a few attempts. If you want to make it go away, you have to visit the url directly and click next a few times, on next start it should log in correctly

I now think that detecting this url (maybe skipping it automatically?) might be a good idea, I’ll try to code that if I have the time

I can’t login. I clear the checkpoint on my every device and browser. I use python3.7.4 and fbchat1.9.6 and up to date last version with pip. my code example:

from fbchat import Client
from fbchat.models import *

client = Client("****@gmail.com", "****")

print("Own id: {}".format(client.uid))

client.send(Message(text="Hi me!"), thread_id=client.uid, thread_type=ThreadType.USER)

client.logout()

error: Logging in @gmail.com… Attempt #1 failed, retrying Traceback (most recent call last): File “C:\Users\mote\OneDrive\Desktop\fbchat\venv\lib\site-packages\fbchat_client.py”, line 209, in login user_agent=“user_agent”, File “C:\Users\mote\OneDrive\Desktop\fbchat\venv\lib\site-packages\fbchat_state.py”, line 153, in login “(Failed on url: {})”.format(r.url) fbchat._exception.FBchatUserError: Login failed. Check email/password. (Failed on url: https://m.facebook.com/checkpoint/?_rdr) Attempt #2 failed, retrying Traceback (most recent call last): File “C:\Users\mote\OneDrive\Desktop\fbchat\venv\lib\site-packages\fbchat_client.py”, line 209, in login user_agent=“user_agent”, File “C:\Users\mote\OneDrive\Desktop\fbchat\venv\lib\site-packages\fbchat_state.py”, line 153, in login “(Failed on url: {})”.format(r.url) fbchat._exception.FBchatUserError: Login failed. Check email/password. (Failed on url: https://m.facebook.com/checkpoint/?_rdr) Attempt #3 failed, retrying Traceback (most recent call last): File “C:\Users\mote\OneDrive\Desktop\fbchat\venv\lib\site-packages\fbchat_client.py”, line 209, in login user_agent=“user_agent”, File “C:\Users\mote\OneDrive\Desktop\fbchat\venv\lib\site-packages\fbchat_state.py”, line 153, in login “(Failed on url: {})”.format(r.url) fbchat._exception.FBchatUserError: Login failed. Check email/password. (Failed on url: https://m.facebook.com/checkpoint/?_rdr) Attempt #4 failed, retrying Traceback (most recent call last): File “C:\Users\mote\OneDrive\Desktop\fbchat\venv\lib\site-packages\fbchat_client.py”, line 209, in login user_agent=“user_agent”, File “C:\Users\mote\OneDrive\Desktop\fbchat\venv\lib\site-packages\fbchat_state.py”, line 153, in login “(Failed on url: {})”.format(r.url) fbchat._exception.FBchatUserError: Login failed. Check email/password. (Failed on url: https://m.facebook.com/checkpoint/?_rdr) Traceback (most recent call last): File “c:/Users/mote/OneDrive/Desktop/fbchat/script.py”, line 4, in <module> client = Client("@gmail.com", “****”) File “C:\Users\mote\OneDrive\Desktop\fbchat\venv\lib\site-packages\fbchat_client.py”, line 103, in init self.login(email, password, max_tries, user_agent=user_agent) File “C:\Users\mote\OneDrive\Desktop\fbchat\venv\lib\site-packages\fbchat_client.py”, line 209, in login user_agent=“user_agent”, File “C:\Users\mote\OneDrive\Desktop\fbchat\venv\lib\site-packages\fbchat_state.py”, line 153, in login “(Failed on url: {})”.format(r.url) fbchat._exception.FBchatUserError: Login failed. Check email/password. (Failed on url: https://m.facebook.com/checkpoint/?_rdr)

Thankyou everyone

How to hacking id

I can’t login with or without cookies.

Code I’m using:

def login_logout():
    cookies = {}
    try:
        # Load the session cookies
        if os.path.isfile('session.json'):
            with open('session.json', 'r') as f:
                cookies = json.load(f)
    except:
        os.remove('session.json')
        # If it fails, never mind, we'll just login again
        # client = CustomClient(email, password, max_tries=1)
    if((not cookies) != True):
        client = CustomClient(email, password, session_cookies=cookies, user_agent=user_agent, max_tries=1)
    else:
        client = CustomClient(email, password, user_agent=user_agent, max_tries=1)
    
    with open('session.json', 'w') as f:
        json.dump(client.getSession(), f)

    print("\nProgram Started!\n")
    client.listen()

Error I’m getting:

Traceback (most recent call last):
  File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python37\lib\site-pa
ckages\fbchat\_client.py", line 175, in setSession
    self._state = State.from_cookies(session_cookies, user_agent=user_agent)
  File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python37\lib\site-pa
ckages\fbchat\_state.py", line 208, in from_cookies
    return cls.from_session(session=session)
  File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python37\lib\site-pa
ckages\fbchat\_state.py", line 186, in from_session
    fb_dtsg = FB_DTSG_REGEX.search(r.text).group(1)
AttributeError: 'NoneType' object has no attribute 'group'

I was able to login with the same code 2 days ago from PC. But then was getting the same error (with the same code) on Termux (Android) with Python 3.8.2, but not on PC running Python 3.7.

How to fix this?

There’s 2different issues in here which would probably make more sense being split up.

  1. getting checkpoint
  2. 2FA and user agent.

Assuming we’re talking about 1), you need to clear the checkpoint on where you’re running the bot using a browser (see #225 )