Alyssa

Login

Mar 10th, 2016
453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.02 KB | None | 0 0
  1. import requests
  2. import sys
  3. import argparse
  4. import json
  5. parser = argparse.ArgumentParser()
  6.  
  7. parser.add_argument("-email", "--user", dest = "email", help = "Email", required = True)
  8. parser.add_argument("-pass", "--password", dest = "password", help = "Password", required = True)
  9. args = parser.parse_args()
  10. #Parse args
  11. clientToken = "6b0a78ec-f4f2-438b-a197-db0b28be776b" #Use your clientToken here!
  12. #clientToken for my launcher, recommend using your own.
  13. data = {"agent":{"name":"Minecraft","version":1},"username":args.email,"password":args.password,"clientToken":clientToken}
  14. #Set data to specifications
  15. data = json.dumps(data)
  16. #Convert data to json for POST
  17. #print("Client Token: " + clientToken)
  18. resp = requests.post("https://authserver.mojang.com/authenticate",data=data)
  19. #Send data
  20. js = resp.json()
  21. #Turn response to JSON
  22. print(str(js))
  23. print("Access Token: " + js["accessToken"])
  24. print("Client Token: " + js["clientToken"])
  25. #Print data for debug info
  26. clientToken = js["clientToken"]
  27. #Get clientToken just in case.
  28. accounts = []
  29. num = 0
  30. #Prepare for loop to create accounts list
  31. for di in js["availableProfiles"]:
  32.   #Loop through profiles
  33.   di["num"] = num
  34.   #Set num to current position
  35.   accounts.append(di)
  36.   #Append updated profile
  37.   num += 1
  38.  
  39. for acc in accounts:
  40.   print(str(acc["num"]) + ": " + acc["name"] + " " + acc["id"][0:8])
  41. #Print accounts
  42. print("Select one")
  43. selected = int(input())
  44. #Select account based on num
  45. print("Selected: " + str(accounts[selected]))
  46. #print("Using access token" + js["accessToken"])
  47. #Display selected acount
  48. db = {"accessToken":js["accessToken"],"clientToken":clientToken,"selectedProfile":{"id":accounts[selected]["id"],"name":accounts[selected]["name"]}}
  49. #Set payload for refresh POST request
  50. db = json.dumps(db)
  51. #Convert to JSON
  52. resp = requests.post("https://authserver.mojang.com/refresh",data=db)
  53. #Send refresh request, setting profile.
  54. rjs = resp.json()
  55. accessToken = rjs["accessToken"]
  56. #Get response and updated accessToken
  57. print(str(rjs))
  58. #Output relevant data.
Advertisement
Add Comment
Please, Sign In to add comment