Created
November 12, 2019 16:59
-
-
Save JacHammer/3e6c0e044cbe81d86a604fba9e7e7fc3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import requests | |
import xml.etree.ElementTree as ET | |
auth_url = "https://authdl.my.com/mygc.php?hint=Auth" | |
header = { | |
'Host': 'authdl.my.com', | |
'Accept':'*/*', | |
'Content-type': 'application/x-www-form-urlencoded', | |
'User-Agent':'Downloader/15170', | |
} | |
# root = ET.fromstring(post_result.text) | |
# auth_credentials = root.attrib | |
# key = {Email; Expires; MinVersion; Origin; RefreshToken; | |
# SessionKey; TermsActual; Timestamp; Uid; Username} | |
if len(sys.argv) != 3: | |
print("argument invalid!\n") | |
print("Useage: GetToken.py [na|eu] [SessionKey]\n") | |
exit(1) | |
if sys.argv[1] not in ['na', 'eu']: | |
print("argument invalid!\n") | |
print("Useage: GetToken.py [na|eu] [SessionKey]\n") | |
exit(1) | |
region = sys.argv[1] | |
session_key = sys.argv[2] | |
def gameLogin(sess_key, region): | |
ProjectId= '2000076' | |
ShardId = 1 | |
if region == 'eu': | |
ShardId = '1' | |
elif region == 'na': | |
ShardId = '2' | |
login_requests = '''<?xml version="1.0" encoding="UTF-8"?><Login SessionKey="{}" ProjectId="{}" ShardId="{}"/>'''.format(sess_key, ProjectId, ShardId) | |
payload = { | |
'User-Agent': 'Downloader/1940', | |
} | |
post =requests.post('https://authdl.my.com/mygc.php?hint=Login', data = login_requests, headers=payload) | |
if post.status_code != 200: | |
print('Error encounter while post requests: \n') | |
print('Error code: ', str(post.status_code), 'content: ', post.text) | |
return -1 | |
else: | |
if 'ErrorCode' in post.text: | |
print('Error: malformed xml: ', post.text) | |
return | |
else: | |
root = ET.fromstring(post.text) | |
login_credentials = root.attrib | |
# key = {Code; Expires; GameAccount; MRACToken} | |
return login_credentials | |
my_login_credentials = gameLogin(session_key, region) | |
print(my_login_credentials) | |
if my_login_credentials == None: | |
print("session key invalid. Please try another session_key") | |
exit(1) | |
game_sess_key = my_login_credentials['Code'] | |
game_account_id = my_login_credentials['GameAccount'] | |
print("GameAccount: " + game_account_id) | |
print("Token: " + game_sess_key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment