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

fix v2 auth for real this time??? #211

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

cjekel
Copy link

@cjekel cjekel commented May 1, 2019

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
Copy link
Author

cjekel commented May 1, 2019

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

@charlesduponpon
Copy link

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

@charlesduponpon
Copy link

@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 #171 (comment) and https://gist.github.com/rtt/10403467#authenticating . None of those methods are working to get the token.

@cjekel
Copy link
Author

cjekel commented May 4, 2019

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.

@charlesduponpon
Copy link

Thanks @cjekel I'll try it right now.

@charlesduponpon
Copy link

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?

@cjekel
Copy link
Author

cjekel commented May 4, 2019

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)

@charlesduponpon
Copy link

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

@ryan713
Copy link

ryan713 commented May 10, 2019

@cjekel session.profile throws error code 400. Basically all pynder functions shows exception 400. But manually requesting for profile like you said here #213 (comment) gives an okay 200 response.

@cjekel
Copy link
Author

cjekel commented May 10, 2019

@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 .

@ryan713
Copy link

ryan713 commented May 10, 2019

@cjekel I got it working with FB_token. Thanks.

@anthony-chen-27
Copy link

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

@fjleon1980
Copy link

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

@cjekel
Copy link
Author

cjekel commented Aug 8, 2019

@fjleon1980 see #127 , but you need to use a loop or manually iterate through the generator with user = next(users)

@brunetton
Copy link

@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

@anthony-chen-27
Copy link

@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.

@cjekel
Copy link
Author

cjekel commented Dec 4, 2019

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.

@dhrumin75
Copy link

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. :/

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

Successfully merging this pull request may close these issues.

8 participants