Closed jsdjsd closed 4 years ago
I wasn't able to fix it.
Though a temp work around was to switch the mobile user agent:
MOBILE_USER_AGENT = "Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/13.2b11866 Mobile/16A366 Safari/605.1.15"
@jsdjsd Thanks! I had the same error but it got solved since then. Is it the case for you too?
I'll close it for now. Feel free to re-open it should you encounter the issue again.
Hello @philipperemy ,
Very sorry to bother you again -and to re-open that thread- but I'm still having authentification issues... And now even working a workaround seems beyond my skills :(
I can't generate the tinder token. I can generate the facebook token with the lines (in tinder_token.py) :
MOBILE_USER_AGENT = "Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/13.2b11866 Mobile/16A366 Safari/605.1.15"
But whenever I try to generate a tinder token, I end up with : None. token = ti.auth_token(fb_auth_token, fb_id)
print('TINDER_TOKEN = {}'.format(token))
if not token:
print('could not get Tinder token. Program will exit.')
sys.exit(0)
To the best of my understanding, it can be linked to a change of Tinder or Facebook API...
In tinder_api.py, auth_token function seems to return no json for req def auth_token(fb_auth_token, fb_user_id): h = headers h.update({'content-type': 'application/json'}) req = requests.post( 'https://api.gotinder.com/auth', headers=h, data=json.dumps({'facebook_token': fb_auth_token, 'facebook_id': fb_user_id}) ) try: return req.json()['token'] except: return None
Does it work on your side ? If not, any clues on how to look at it ?
Thanks a lot !
Did you make a lot of calls? It's possible that they blocked you for a few days. It happened to me 2 times.
I'm using this:
import re
import robobrowser
MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; U; en-gb; KFTHWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.16 Safari/535.19"
FB_AUTH = "https://www.facebook.com/v2.6/dialog/oauth?redirect_uri=fb464891386855067%3A%2F%2Fauthorize%2F&display=touch&state=%7B%22challenge%22%3A%22IUUkEUqIGud332lfu%252BMJhxL4Wlc%253D%22%2C%220_auth_logger_id%22%3A%2230F06532-A1B9-4B10-BB28-B29956C71AB1%22%2C%22com.facebook.sdk_client_state%22%3Atrue%2C%223_method%22%3A%22sfvc_auth%22%7D&scope=user_birthday%2Cuser_photos%2Cuser_education_history%2Cemail%2Cuser_relationship_details%2Cuser_friends%2Cuser_work_history%2Cuser_likes&response_type=token%2Csigned_request&default_audience=friends&return_scopes=true&auth_type=rerequest&client_id=464891386855067&ret=login&sdk=ios&logger_id=30F06532-A1B9-4B10-BB28-B29956C71AB1&ext=1470840777&hash=AeZqkIcf-NEW6vBd"
def get_access_token(email, password):
s = robobrowser.RoboBrowser(user_agent=MOBILE_USER_AGENT, parser="lxml")
s.open(FB_AUTH)
f = s.get_form()
f["pass"] = password
f["email"] = email
s.submit_form(f)
f = s.get_form()
s.submit_form(f, submit=f.submit_fields['__CONFIRM__'])
access_token = re.search(r"access_token=([\w\d]+)", s.response.content.decode()).groups()[0]
token = ti.auth_token(fb_auth_token, fb_id)
And I can confirm that it works
Thanks for the quick reply, I was making lots of calls, so I guess you must be right :)
@jsdjsd what you can do is to cache this token and re-use the cache token. If an error happens, generate a new one. I guess it will be much more efficient and will save you those troubles :)
@philipperemy Thanks :) I'm definitely gonna do that
Good luck!
Hey Philippe, Long time no talk ! I hope you're well :) So I just thought I would share, in python 3.6(at least) the script might run because of robobrowser. It can't handle the facebook redirect url... I have a hack that works (I know you will work out something nicer), I just thought I should share: My tinder_token.py: import re import robobrowser import requests
MOBILE_USER_AGENT = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/13.2b11866 Mobile/16A366 Safari/605.1.15'
def get_access_token(email, password): s = robobrowser.RoboBrowser(user_agent=MOBILE_USER_AGENT, parser="lxml") s.open(FB_AUTH) 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]
except requests.exceptions.InvalidSchema as browserAddress:
#print(type(browserAddress))
access_token = re.search(r"access_token=([\w\d]+)",str(browserAddress)).groups()[0]
return access_token
@jsdjsd thanks for sharing :) I haven't had time to look at it recently but I'll definitely add in the code base soon!
Hey, What about : def auth_token(fb_auth_token, fb_user_id): h = headers h.update({'content-type': 'application/json'}) req = requests.post(
'https://api.gotinder.com/v2/auth/login/facebook',
headers=h,
#data=json.dumps({'facebook_token': fb_auth_token, 'facebook_id': fb_user_id})
#data=json.dumps({'facebook_token': fb_auth_token}
data=json.dumps({'token': fb_auth_token})
)
try:
return req.json()['data']['api_token']
except:
return None
@jsdjsd hey thanks for that!
So how should I replace the function get_access_token
to make it work again as before?
I'm getting this error when trying to get FB token. Does it work on your end @jsdjsd ?
raise exceptions.InvalidSubmitError()
robobrowser.exceptions.InvalidSubmitError
Hey @philipperemy ,
Yes, it's fine on my side.
In tinder_token.py : import re
import robobrowser import requests
MOBILE_USER_AGENT = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/13.2b11866 Mobile/16A366 Safari/605.1.15'
def get_access_token(email, password): s = robobrowser.RoboBrowser(user_agent=MOBILE_USER_AGENT, parser="lxml") s.open(FB_AUTH) 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]
except requests.exceptions.InvalidSchema as browserAddress:
#print(type(browserAddress))
access_token = re.search(r"access_token=([\w\d]+)",str(browserAddress)).groups()[0]
#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
In tinder_api.py : def auth_token(fb_auth_token, fb_user_id): h = headers h.update({'content-type': 'application/json'}) req = requests.post(
'https://api.gotinder.com/v2/auth/login/facebook',
headers=h,
#data=json.dumps({'facebook_token': fb_auth_token, 'facebook_id': fb_user_id})
#data=json.dumps({'facebook_token': fb_auth_token}
data=json.dumps({'token': fb_auth_token})
)
try:
return req.json()['data']['api_token']
except:
return None
Let me know if it works with this !
I saw some chat bots for that yeah it's not too difficult to make :)
werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.
Still does not work for me! can you give me your dependencies by doing
pip freeze
I suspect I'm using a newer version of a package that somehow does not work. Thanks!
@philipperemy Hey,
Sorry it's messy : absl-py==0.8.0 alabaster==0.7.12 anaconda-client==1.7.2 anaconda-navigator==1.9.7 anaconda-project==0.8.3 asn1crypto==1.0.1 astor==0.8.0 astroid==2.3.1 astropy==3.2.2 atomicwrites==1.3.0 attrs==19.2.0 Babel==2.7.0 backcall==0.1.0 backports.functools-lru-cache==1.5 backports.os==0.1.1 backports.shutil-get-terminal-size==1.0.0 backports.tempfile==1.0 backports.weakref==1.0.post1 beautifulsoup4==4.8.0 bitarray==1.0.1 bkcharts==0.2 bleach==3.1.0 bokeh==1.3.4 boto==2.49.0 Bottleneck==1.2.1 certifi==2019.9.11 cffi==1.12.3 chardet==3.0.4 Click==7.0 cloudpickle==1.2.2 clyent==1.2.2 colorama==0.4.1 comtypes==1.1.7 conda==4.7.12 conda-build==3.18.8 conda-package-handling==1.6.0 conda-verify==3.4.2 contextlib2==0.6.0 cryptography==2.7 cycler==0.10.0 Cython==0.29.13 cytoolz==0.10.0 dask==2.5.2 decorator==4.4.0 defusedxml==0.6.0 distributed==2.5.2 docutils==0.15.2 entrypoints==0.3 et-xmlfile==1.0.1 fastcache==1.1.0 filelock==3.0.12 Flask==1.1.1 fsspec==0.5.2 future==0.17.1 gast==0.3.2 gevent==1.4.0 glob2==0.7 google-images-download==2.8.0 google-pasta==0.1.7 greenlet==0.4.15 grpcio==1.23.0 h5py==2.9.0 HeapDict==1.0.1 html5lib==1.0.1 idna==2.8 imageio==2.6.0 imagesize==1.1.0 importlib-metadata==0.23 ipykernel==5.1.2 ipython==7.8.0 ipython-genutils==0.2.0 ipywidgets==7.5.1 isort==4.3.21 itsdangerous==1.1.0 jdcal==1.4.1 jedi==0.15.1 Jinja2==2.10.3 joblib==0.13.2 json5==0.8.5 jsonschema==3.0.2 jupyter==1.0.0 jupyter-client==5.3.3 jupyter-console==6.0.0 jupyter-core==4.5.0 jupyterlab==1.1.4 jupyterlab-server==1.0.6 Keras==2.3.0 Keras-Applications==1.0.8 Keras-Preprocessing==1.1.0 keyring==18.0.0 kiwisolver==1.1.0 lazy-object-proxy==1.4.2 libarchive-c==2.8 llvmlite==0.29.0 locket==0.2.0 lxml==4.4.1 Markdown==3.1.1 MarkupSafe==1.1.1 matplotlib==3.1.1 mccabe==0.6.1 menuinst==1.4.16 mistune==0.8.4 mkl-fft==1.0.14 mkl-random==1.1.0 mkl-service==2.3.0 mock==3.0.5 more-itertools==7.2.0 mpmath==1.1.0 msgpack==0.6.1 multipledispatch==0.6.0 navigator-updater==0.2.1 nbconvert==5.6.0 nbformat==4.4.0 networkx==2.3 nltk==3.4.5 nose==1.3.7 notebook==6.0.1 numba==0.45.1 numexpr==2.7.0 numpy==1.16.5 numpydoc==0.9.1 olefile==0.46 opencv-python==4.1.1.26 openpyxl==3.0.0 packaging==19.2 pandas==0.25.1 pandocfilters==1.4.2 parso==0.5.1 partd==1.0.0 path.py==12.0.1 pathlib2==2.3.5 patsy==0.5.1 pep8==1.7.1 pickleshare==0.7.5 Pillow==6.2.0 pkginfo==1.5.0.1 pluggy==0.13.0 ply==3.11 prometheus-client==0.7.1 prompt-toolkit==2.0.10 protobuf==3.9.2 psutil==5.6.3 py==1.8.0 pycodestyle==2.5.0 pycosat==0.6.3 pycparser==2.19 pycrypto==2.6.1 pycurl==7.43.0.3 pydot==1.4.1 pyflakes==2.1.1 Pygments==2.4.2 pylint==2.4.2 pyodbc==4.0.27 pyOpenSSL==19.0.0 pyparsing==2.4.2 pyreadline==2.1 pyrsistent==0.15.4 PySocks==1.7.1 pytest==5.2.1 pytest-arraydiff==0.3 pytest-astropy==0.5.0 pytest-doctestplus==0.4.0 pytest-openfiles==0.4.0 pytest-remotedata==0.3.2 python-dateutil==2.8.0 pytz==2019.3 PyWavelets==1.0.3 pywin32==223 pywinpty==0.5.5 PyYAML==5.1.2 pyzmq==18.1.0 QtAwesome==0.6.0 qtconsole==4.5.5 QtPy==1.9.0 requests==2.22.0 robobrowser==0.5.3 rope==0.14.0 ruamel-yaml==0.15.46 scikit-image==0.15.0 scikit-learn==0.21.3 scipy==1.3.1 seaborn==0.9.0 selenium==3.141.0 Send2Trash==1.5.0 simplegeneric==0.8.1 singledispatch==3.4.0.3 six==1.12.0 snowballstemmer==2.0.0 sortedcollections==1.1.2 sortedcontainers==2.1.0 soupsieve==1.9.3 Sphinx==2.2.0 sphinxcontrib-applehelp==1.0.1 sphinxcontrib-devhelp==1.0.1 sphinxcontrib-htmlhelp==1.0.2 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.2 sphinxcontrib-serializinghtml==1.1.3 sphinxcontrib-websupport==1.1.2 spyder==3.3.6 spyder-kernels==0.5.2 SQLAlchemy==1.3.9 statsmodels==0.10.1 sympy==1.4 tables==3.5.2 tblib==1.4.0 tensorboard==1.14.0 tensorflow==1.14.0 tensorflow-estimator==1.14.0 termcolor==1.1.0 terminado==0.8.2 testpath==0.4.2 toolz==0.10.0 tornado==6.0.3 tqdm==4.36.1 traitlets==4.3.3 unicodecsv==0.14.1 urllib3==1.24.2 wcwidth==0.1.7 webencodings==0.5.1 Werkzeug==0.16.0 wget==3.2 widgetsnbextension==3.5.1 win-inet-pton==1.1.0 win-unicode-console==0.5 wincertstore==0.2 wrapt==1.11.2 xlrd==1.2.0 XlsxWriter==1.2.1 xlwings==0.15.10 xlwt==1.3.0 zict==1.0.0 zipp==0.6.0
Traceback (most recent call last):
File "main.py", line 98, in <module>
main()
File "main.py", line 22, in main
fb_auth_token = get_access_token(credentials['FB_EMAIL_ADDRESS'], credentials['FB_PASSWORD'])
File "/Users/premy/PycharmProjects/Deep-Learning-Tinder/tinder_token.py", line 21, in get_access_token
s.submit_form(f, submit=f.submit_fields['CONFIRM'])
File "/Users/premy/PycharmProjects/Deep-Learning-Tinder/venv/lib/python3.6/site-packages/werkzeug/datastructures.py", line 795, in __getitem__
raise exceptions.BadRequestKeyError(key)
werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.
Still the same so I'll probably use a second account and it should work.
The best for a chatbot would be to have access to anonymized data of the Tinder chats..
Hum still it does not work with my second account. How come it can work with your account! Did you retry recently?
Ok it worked. I updated the code :)
Thanks by the way your function tinder auth worked perfectly!!
Hey Philippe, Sorry to reopen the issue !
It would seem that facebook changed something as I am not able to retrieve the access token anymore.
It might be the FB_AUTH url ...
Anyone has a fix ?
Hi !
Thanks for all the hard work.
I have an issue when running :"python main.py"
AT line : fb_auth_token = get_access_token(credentials['FB_EMAIL_ADDRESS'], credentials['FB_PASSWORD']) The error is : TooManyRedirects: Exceeded 30 redirects.
Any chance you can have a look at it ?
Many thanks,