pynder icon indicating copy to clipboard operation
pynder copied to clipboard

fix v2 auth for real this time???

Open cjekel opened this issue 5 years ago • 18 comments

Fixes facebook authentication for new v2 api.

Changes:

  • new auth url
  • initial auth is performed outside of session
  • auth will now pass the requests code if failed
  • updated headers
  • headers are now stored in api
  • session headers are only updated once
  • New default in api._requsts. Was data={}, now is data=None (This was causing 403)
  • Rolled version to 0.0.14; because why not

Test are passing on my computer...

Closes: #208

cjekel avatar May 01 '19 20:05 cjekel

travis-ci is throwing a request code 401 (unauthorized login). Could it be possible that the token used in test.ini is no longer valid?

Anyone care to test if this works for you? @charlesduponpon

cjekel avatar May 01 '19 20:05 cjekel

Thanks for your work @cjekel I'll try it out!

charlesduponpon avatar May 04 '19 10:05 charlesduponpon

@cjekel I wanted to try but it seems that facebook changed its API a bit too much and old ways of getting the token are not working. For example, I tried https://gist.github.com/taseppa/66fc7239c66ef285ecb28b400b556938 and https://github.com/charliewolf/pynder/issues/171#issuecomment-445463745 and https://gist.github.com/rtt/10403467#authenticating . None of those methods are working to get the token.

charlesduponpon avatar May 04 '19 11:05 charlesduponpon

If this works https://github.com/fbessez/Tinder/blob/master/phone_auth_token.py then your facebook_token should be this line access_token = validate_response["access_token"]

otherwise that script outputs your X-Auth-Token for pynder...

The MITM methods are a bit trickier to set up.

cjekel avatar May 04 '19 15:05 cjekel

Thanks @cjekel I'll try it right now.

charlesduponpon avatar May 04 '19 15:05 charlesduponpon

I tried with https://github.com/fbessez/Tinder/blob/master/phone_auth_token.py by printing the access_token . I get a string which is 112 chars long. I tried the following code:

import requests

facebook_token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
print(len(facebook_token))
USER_AGENT = "Tinder/7.5.3 (iPhone; iOS 10.3.2; Scale/2.00)"

HEADERS = {
    'app_version': '6.9.4',
    'platform': 'ios',
    "content-type": "application/json",
    "User-agent": USER_AGENT,
    "Accept": "application/json"
}

new_url = 'https://api.gotinder.com/v2/auth/login/facebook'

new_data = {"token": facebook_token}

r_new = requests.post(new_url, headers=HEADERS, json=new_data)

print(r_new.status_code)
print(r_new.json())

And I got:

112
401
{'meta': {'status': 401}, 'error': {'code': 60001}}

Do you think that the facebook token is wrong? I also got the tinder token which is in this form: xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx Is this useful?

charlesduponpon avatar May 04 '19 15:05 charlesduponpon

Do you think that the facebook token is wrong?

Yes it looks like the facebook token is wrong unfortunately.

I also got the tinder token which is in this form: xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx Is this useful?

Yes, and this is the good news. That should be the X-Auth-Token, which you can use to log into pynder. I'll need to rework tindetheus to use X-Auth-Token, but you can test something like this.

import pynder
X_Auth_Token = 'xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx'
session = pynder.Session(XAuthToken=X_Auth_Token)
print(session.profile)

cjekel avatar May 04 '19 15:05 cjekel

I tried your code (with your branch, cjekel:v2auth_newhead) and my tinder name appeared. I supposed it's good news then :)

charlesduponpon avatar May 04 '19 15:05 charlesduponpon

@cjekel session.profile throws error code 400. Basically all pynder functions shows exception 400. But manually requesting for profile like you said here https://github.com/charliewolf/pynder/issues/213#issuecomment-489472063 gives an okay 200 response.

ryan713 avatar May 10 '19 16:05 ryan713

@ryan713 I'm not sure what's going on then. How are you using this pynder version? with facebook_token or XAuthToken when you create the Session?

This PR of pynder is working for me right now with facebook_token.


To install this PR

git clone https://github.com/charliewolf/pynder.git
cd pynder
git fetch origin +refs/pull/211/merge
git checkout -qf FETCH_HEAD
python -m pip install --force-reinstall --no-deps .

cjekel avatar May 10 '19 16:05 cjekel

@cjekel I got it working with FB_token. Thanks.

ryan713 avatar May 10 '19 17:05 ryan713

Everything works on my computer, I used https://github.com/fbessez/Tinder/blob/master/phone_auth_token.py to get my token.

anthony-chen-27 avatar Jun 29 '19 00:06 anthony-chen-27

i am able to connect with my fb id and token, however when i run: users = session.nearby_users() user = users[0]

i get an error on the last line: TypeError: 'generator' object is not subscriptable I am using python 3.7

fjleon1980 avatar Aug 08 '19 17:08 fjleon1980

@fjleon1980 see https://github.com/charliewolf/pynder/issues/127 , but you need to use a loop or manually iterate through the generator with user = next(users)

cjekel avatar Aug 08 '19 19:08 cjekel

@simpleistruth

Everything works on my computer, I used https://github.com/fbessez/Tinder/blob/master/phone_auth_token.py to get my token.

How long is this token valid ? I'm using Facebook tokens generated by hand for now, but they are only valid for one hour :s Maybe the sms generated tokens are valid longer ?

Thanks

brunetton avatar Sep 05 '19 10:09 brunetton

@simpleistruth

Everything works on my computer, I used https://github.com/fbessez/Tinder/blob/master/phone_auth_token.py to get my token.

How long is this token valid ? I'm using Facebook tokens generated by hand for now, but they are only valid for one hour :s Maybe the sms generated tokens are valid longer ?

Thanks

my tokens have also lasted about a hr.

anthony-chen-27 avatar Sep 05 '19 17:09 anthony-chen-27

It appears this fix works on Python 3.X, but not on Python 2.7. Does anyone know why that may be?

EDIT: OOOPS! This PR is indeed working on Python 2.7.

cjekel avatar Dec 04 '19 22:12 cjekel

i am able to connect with my fb id and token:

@fjleon1980 can you explain how to get FB token and id, I followed #171(comment) and got a 198 characters long FB token and numeric id. When I tried running print(session.profile) it throws JSONDecodeError. I also tried following https://github.com/fbessez/Tinder/blob/master/phone_auth_token.py to get the XAuthToken (36 characters long) but almost all the pynder functions are showing 400 error.

I have all the packages upgraded but still no luck. :/

dhrumin75 avatar Apr 15 '20 13:04 dhrumin75