Poodletooth-iLand/toontown/toonbase/ClientStartRemoteDB.py

31 lines
972 B
Python
Raw Normal View History

2015-05-18 21:11:33 -05:00
import json
import os
import requests
2015-07-04 14:13:29 -05:00
from pandac.PandaModules import *
2015-05-18 21:11:33 -05:00
username = os.environ['ttsUsername']
password = os.environ['ttsPassword']
2015-07-04 14:13:29 -05:00
accountServerEndpoint = 'http://www.toontownstride.com/api/'
session = requests.Session()
csrf_query = session.get(accountServerEndpoint + 'login/')
csrf = session.cookies.get_dict().get('csrftoken', '')
request = session.post(
2015-05-18 21:11:33 -05:00
accountServerEndpoint + 'login/',
2015-07-04 14:13:29 -05:00
data={'username': username, 'password': password, 'csrfmiddlewaretoken': csrf})
2015-05-18 21:11:33 -05:00
try:
2015-07-04 14:13:29 -05:00
response = json.loads('{'+request.text.split('{', 1)[1]) # so that we ignore the csrf token
2015-05-18 21:11:33 -05:00
except ValueError:
print "Couldn't verify account credentials."
else:
2015-07-04 14:13:29 -05:00
if response['status'] != 7:
print response['message']
2015-05-18 21:11:33 -05:00
else:
os.environ['TTS_PLAYCOOKIE'] = response['token']
2015-07-04 14:13:29 -05:00
os.environ['TTS_GAMESERVER'] = response['gameserver']
2015-06-05 00:32:41 -05:00
2015-05-18 21:11:33 -05:00
# Start the game:
import toontown.toonbase.ClientStart