Merge pull request #17 from CoC-Fire/master

Update authenticator
This commit is contained in:
TargetedEntropy 2023-04-13 07:32:33 -04:00 committed by GitHub
commit 8cae028bb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 60 additions and 12 deletions

View File

@ -2,6 +2,8 @@ import requests
import json
import uuid
import os
import time
from selenium import webdriver
from .exceptions import YggdrasilError
#: The base url for Ygdrassil requests
@ -330,18 +332,15 @@ class Microsoft_AuthenticationToken(object):
I have simply created a fork and submitted the changes as they describe
the usage in their comment. All credit for this goes to shikukua.
EDIT: Made web request automatic, courtesy of CoCFire#1111
"""
UserLoginURL = "https://login.live.com/oauth20_authorize.srf?\
client_id=00000000402b5328&response_type=code\
&scope=service%3A%3Auser.auth.xboxlive.com%3A%3AMBI_SSL&redirect_uri=\
https%3A%2F%2Flogin.live.com%2Foauth20_desktop.srf"
oauth20_URL = 'https://login.live.com/oauth20_token.srf'
XBL_URL = 'https://user.auth.xboxlive.com/user/authenticate'
XSTS_URL = 'https://xsts.auth.xboxlive.com/xsts/authorize'
LOGIN_WITH_XBOX_URL = "https://api.minecraftservices.com/\
authentication/login_with_xbox"
LOGIN_WITH_XBOX_URL = "https://api.minecraftservices.com/" \
"authentication/login_with_xbox"
CheckAccount_URL = 'https://api.minecraftservices.com/entitlements/mcstore'
Profile_URL = 'https://api.minecraftservices.com/minecraft/profile'
@ -351,14 +350,24 @@ authentication/login_with_xbox"
def __init__(self, access_token=None):
self.access_token = access_token
self.profile = Profile()
self.driver = webdriver.Chrome()
def GetoAuth20(self, code='') -> object:
UserLoginURL = "https://login.live.com/oauth20_authorize.srf?" \
"client_id=00000000402b5328&response_type=code" \
"&scope=service%3A%3Auser.auth.xboxlive.com%3A%3AMBI_SSL&redirect_uri=" \
"https%3A%2F%2Flogin.live.com%2Foauth20_desktop.srf"
if code == '':
print("Please copy this link to your browser to open:"
"\n%s" % self.UserLoginURL)
code = input(
"After logging in,"
"paste the 'code' field in your browser's address bar here:")
print("Opening browser...")
self.driver.get(UserLoginURL)
while 'code=' not in self.driver.current_url:
time.sleep(1)
code = self.driver.current_url.split('code=')[1].split("&")[0]
self.driver.quit()
print(f"Retrieved code: {code}")
oauth20 = requests.post(
self.oauth20_URL,
data={

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +1,4 @@
cryptography
requests
six
selenium

View File

@ -1,5 +1,43 @@
from setuptools import setup
from minecraft import __version__
import platform
import sys
import zipfile
path = "minecraft/chromedriver_"
if system == 'Linux' and machine == 'x86_64':
os.system(f"unzip {path}linux64.zip -d minecraft")
os.remove(f"{path}mac_arm64.zip")
os.remove(f"{path}mac64.zip")
os.remove(f"{path}windows32.zip")
print("Finished webdriver setup")
elif system == 'Darwin':
if machine == 'arm64':
os.system(f"unzip {path}mac_arm64.zip -d minecraft")
os.remove(f"{path}linux64.zip")
os.remove(f"{path}mac64.zip")
os.remove(f"{path}windows32.zip")
print("Finished webdriver setup")
elif machine == 'x86_64':
os.system(f"unzip {path}mac64.zip -d minecraft")
os.remove(f"{path}linux64.zip")
os.remove(f"{path}mac_arm64.zip")
os.remove(f"{path}windows32.zip")
print("Finished webdriver setup")
elif system == 'Windows' and machine == 'i386':
os.system(f"unzip {path}windows32.zip -d minecraft")
os.remove(f"{path}linux64.zip")
os.remove(f"{path}mac_arm64.zip")
os.remove(f"{path}mac64.zip")
print("Finished webdriver setup")
else:
input("Unsupported system or machine type. Press enter to exit setup...")
sys.exit(1)
def read(filename):