forked from fbessez/Tinder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phone_auth_token.py
43 lines (35 loc) · 1.62 KB
/
phone_auth_token.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import requests
import json
CODE_REQUEST_URL = "https://api.gotinder.com/v2/auth/sms/send?auth_type=sms"
CODE_VALIDATE_URL = "https://api.gotinder.com/v2/auth/sms/validate?auth_type=sms"
TOKEN_URL = "https://api.gotinder.com/v2/auth/login/sms"
HEADERS = {'user-agent': 'Tinder/11.4.0 (iPhone; iOS 12.4.1; Scale/2.00)', 'content-type': 'application/json'}
def send_otp_code(phone_number):
data = {'phone_number': phone_number}
r = requests.post(CODE_REQUEST_URL, headers=HEADERS, data=json.dumps(data), verify=False)
print(r.url)
response = r.json()
if(response.get("data")['sms_sent'] == False):
return False
else:
return True
def get_refresh_token(otp_code, phone_number):
data = {'otp_code': otp_code, 'phone_number': phone_number}
r = requests.post(CODE_VALIDATE_URL, headers=HEADERS, data=json.dumps(data), verify=False)
print(r.url)
response = r.json()
if(response.get("data")["validated"] == False):
return False
else:
return response.get("data")["refresh_token"]
def get_api_token(refresh_token):
data = {'refresh_token': refresh_token }
r = requests.post(TOKEN_URL, headers=HEADERS, data=json.dumps(data), verify=False)
print(r.url)
response = r.json()
return response.get("data")["api_token"]
phone_number = input("Please enter your phone number under the international format (country code + number): ")
log_code = send_otp_code(phone_number)
otp_code = input("Please enter the code you've received by sms: ")
refresh_token = get_refresh_token(otp_code, phone_number)
print("Here is your Tinder token: " + str(get_api_token(refresh_token)))