Skip to content

Instantly share code, notes, and snippets.

@jenrik
Last active May 19, 2020 07:31
Show Gist options
  • Save jenrik/5149944 to your computer and use it in GitHub Desktop.
Save jenrik/5149944 to your computer and use it in GitHub Desktop.
[DEPRECATED] Minecraft login script for Python 3. Use as you wish as long as you give me credit.
import http.client, urllib.parse, getpass
username = input("Username: ")
password = getpass.getpass(prompt='Password: ', stream=None)
params = urllib.parse.urlencode({'user': username, 'password': password, 'version': 12})
headers = {"Content-type": "application/x-www-form-urlencoded"}
conn = http.client.HTTPConnection("login.minecraft.net")
conn.request("POST", "", params, headers)
response = conn.getresponse()
print(response.status, response.reason)
data = response.read()
data = data.decode("utf-8").split(':')
print("Current minecraft version: " + data[0])
print("Minecraft username: " + data[2])
print("Session ID: " + data[3])
print("UID: " + data[4])
conn.close()
@jenrik
Copy link
Author

jenrik commented May 18, 2020

@shai The login protocol has changed since I posted this script 7 years ago. Try taking a look at https://wiki.vg/Authentication and the other pages on that wiki

@shai
Copy link

shai commented May 18, 2020

@jenrik yea I thought so, and thought you might want to update the code :)

@jenrik
Copy link
Author

jenrik commented May 19, 2020

I abandoned this scripts years ago, and I have no intention of updating it. If anybody needs a script to login to Minecraft you should read https://wiki.vg/Authentication and do your own implementation instead of trying to fix this crappy script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment