Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem on getting auth token #126

Open
aspirez4 opened this issue Mar 8, 2021 · 2 comments
Open

Problem on getting auth token #126

aspirez4 opened this issue Mar 8, 2021 · 2 comments

Comments

@aspirez4
Copy link

aspirez4 commented Mar 8, 2021

Problem:
Facebook have added cookie window which have to be accepted which results to the following error
400 Bad Request: The browser (or proxy) sent a request that this server could not understand.

Solution:
Add this code on line 16 here https://github.com/fbessez/Tinder/blob/master/fb_auth_token.py
f = s.get_form()
s.submit_form(f)

Or the whole function looks like this

def get_fb_access_token(email, password):
    s = robobrowser.RoboBrowser(user_agent=MOBILE_USER_AGENT, parser="lxml")
    s.open(FB_AUTH)
    f = s.get_form()
    s.submit_form(f)
    f = s.get_form()
    f["pass"] = password
    f["email"] = email
    s.submit_form(f)
    f = s.get_form()
    try:
        s.submit_form(f, submit=f.submit_fields['__CONFIRM__'])
        access_token = re.search(
            r"access_token=([\w\d]+)", s.response.content.decode()).groups()[0]
        return access_token
    except requests.exceptions.InvalidSchema as browserAddress:
        access_token = re.search(
            r"access_token=([\w\d]+)",str(browserAddress)).groups()[0]
        return access_token
    except Exception as ex:
        print("access token could not be retrieved. Check your username and password.")
        print("Official error: %s" % ex)
        return {"error": "access token could not be retrieved. Check your username and password."}
@Edvards79
Copy link

Change MOBILE_USER_AGENT variable to Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; SCH-I535 Build/KOT49H) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30. The old one seems to be outdated for facebook and it shows error message instead of the login form.

@Meleagrista
Copy link

Is there anything I can try?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants