Tinder
Tinder copied to clipboard
Problem on getting auth token
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."}
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.
Is there anything I can try?