Last active
May 22, 2025 23:10
-
-
Save brostosjoined/3bb7b96c1f6397d389427f46e104005f to your computer and use it in GitHub Desktop.
Get your discord TOKEN using email and password (http.client).
This file contains hidden or 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 http.client | |
import json | |
login_json = { | |
"login": None, | |
"password": None, | |
"undelete": False, | |
"login_source": None, | |
"gift_code_sku_id": None | |
} | |
mfa_json = { | |
"code": None, | |
"ticket": None, | |
"login_source": None, | |
"gift_code_sku_id": None | |
} | |
X_Super_Properties = {"os":"Windows","browser":"Chrome","browser_user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36"} | |
headers = { | |
'User-Agent': X_Super_Properties["browser_user_agent"], | |
'Content-Type': 'application/json', | |
'X-Super-Properties': base64.b64encode(json.dumps(X_Super_Properties).encode()).decode(), | |
} | |
def get_token_http(email: str, password: str) -> str: | |
conn = http.client.HTTPSConnection("discord.com") | |
login_json['login'] = email | |
login_json['password'] = password | |
login_payload = json.dumps(login_json, separators=(',', ':')) | |
headers['Content-Length'] = str(len(login_payload)) | |
conn.request("POST", "/api/v9/auth/login", login_payload, headers) | |
login_res = conn.getresponse().read() | |
try: | |
error = json.loads(login_res)['errors']['login']['_errors'][0]['code'] | |
print("Invalid Email" if error == "EMAIL_TYPE_INVALID_EMAIL" else "Incorrect password") | |
return | |
except KeyError: | |
try: | |
captcha = json.loads(login_res)["captcha_key"] | |
print("Did you mistype your email?") | |
return | |
except KeyError: | |
pass | |
try: | |
token = json.loads(login_res)['token'] | |
except KeyError: | |
ticket = json.loads(login_res)['ticket'] | |
code = input('Input 2FA/Discord backup code: ').strip() | |
mfa_json['ticket'] = ticket | |
# Discord mfa/2fa code | |
if len(code) == 6 and code.isdigit(): | |
mfa_json['code'] = code | |
mfa_payload = json.dumps(mfa_json, separators=(',', ':')) | |
headers['Content-Length'] = str(len(mfa_payload)) | |
conn.request("POST", "/api/v9/auth/mfa/totp", mfa_payload, headers) | |
mfa_res = conn.getresponse().read() | |
try: | |
if json.loads(mfa_res)['code'] == 60008: | |
print("Invalid two-factor code") | |
return | |
except KeyError: | |
pass | |
token = json.loads(mfa_res)['token'] | |
# Discord backup code | |
elif len(code) == 9 and code.find("-") == 4: | |
code = code.replace("-", "") | |
mfa_json["code"] = code | |
backup_payload = json.dumps(mfa_json, separators=(',', ':')) | |
headers['Content-Length'] = str(len(backup_payload)) | |
conn.request("POST", "/api/v9/auth/mfa/backup", backup_payload, headers) | |
backup_res = conn.getresponse().read() | |
try: | |
if json.loads(backup_res)['code'] == 60008: | |
print("Invalid backup code") | |
return | |
except KeyError: | |
pass | |
token = json.loads(backup_res)['token'] | |
else: | |
print("Short/Incorrect two-factor code format") | |
return | |
return token |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Removed requests as it adds unecessary headers making the request to fail.