Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant login Auth Failed #218

Open
AinRyzen opened this issue May 18, 2024 · 5 comments
Open

Cant login Auth Failed #218

AinRyzen opened this issue May 18, 2024 · 5 comments
Labels
question Further information is requested

Comments

@AinRyzen
Copy link

Traceback (most recent call last):
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 1344, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\http\client.py", line 1336, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\http\client.py", line 1382, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\http\client.py", line 1331, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\http\client.py", line 1091, in _send_output
self.send(msg)
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\http\client.py", line 1035, in send
self.connect()
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\http\client.py", line 1470, in connect
super().connect()
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\http\client.py", line 1001, in connect
self.sock = self._create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\socket.py", line 828, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\socket.py", line 963, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
socket.gaierror: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\site-packages\portablemc\http.py", line 96, in http_request
res: HTTPResponse = urllib.request.urlopen(req, context=ctx)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 215, in urlopen
return opener.open(url, data, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 515, in open
response = self._open(req, data)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 532, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 492, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 1392, in https_open
return self.do_open(http.client.HTTPSConnection, req,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 1347, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 11001] getaddrinfo failed>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\site-packages\portablemc\auth.py", line 164, in request
res = http_request("POST", f"https://authserver.mojang.com/{req}",
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\site-packages\portablemc\http.py", line 103, in http_request
raise HttpError(HttpResponse(None), method, url, error)
portablemc.http.HttpError: (<HttpResponse 0>, 'POST', 'https://authserver.mojang.com/authenticate', URLError(gaierror(11001, 'getaddrinfo failed')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "i:\Meine Ablage\projekts\VistaLauncher\builds\Vista\test.py", line 15, in
version.auth_session = YggdrasilAuthSession.authenticate(client_id, email, password)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\site-packages\portablemc\auth.py", line 144, in authenticate
_, res = cls.request("authenticate", {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\site-packages\portablemc\auth.py", line 175, in request
raise AuthError(error.res.json()["errorMessage"])
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

@AinRyzen AinRyzen changed the title Cant login Auth Failded Cant login Auth Failed May 18, 2024
@mindstorm38
Copy link
Owner

The Yggdrasil authentication is deprecated and no longer supported by Mojang, I'll probably fix this bad error message, but I can't make it work!

@AinRyzen
Copy link
Author

AinRyzen commented May 18, 2024

The Yggdrasil authentication is deprecated and no longer supported by Mojang, I'll probably fix this bad error message, but I can't make it work!

Oh, that's unfortunate, I tried the Microsoft Azure logging method, but I don't know what the following variables should have been request_body, id_token, and thus I don't know how I should set up the azure application just in general there is very little information about the Microsoft login in the docs and combining that with the lack of tutorials for this package is really hard to get into portable MC, but I do really appreciate your work and effort that you put into this project

@mindstorm38
Copy link
Owner

Ok so you're using the API, to be honest the MS auth bothers me, you can obtain some information on how to set up the Azure APP on https://wiki.vg/Microsoft_Authentication_Scheme, for PortableMC in particular, I suggest that you read this snippet from the CLI, it shows you which URLs and methods to call in order.

@mindstorm38 mindstorm38 added the question Further information is requested label May 18, 2024
@AinRyzen
Copy link
Author

AinRyzen commented May 18, 2024

Ok so you're using the API, to be honest the MS auth bothers me, you can obtain some information on how to set up the Azure APP on https://wiki.vg/Microsoft_Authentication_Scheme, for PortableMC in particular, I suggest that you read this snippet from the CLI, it shows you which URLs and methods to call in order.

I am just wondering if you saw this part of the wiki, it's almost everything that you have to use
for the minecraft authentication, I have to automate this and rewrite your code a bit and I think it would work https://gist.github.com/dewycube/223d4e9b3cddde932fbbb7cfcfb96759
Update: Yesss, it does work

@mindstorm38
Copy link
Owner

mindstorm38 commented May 19, 2024

This is almost what I'm doing in the API, so you should not need to do that manually.

@classmethod
def authenticate_base(cls, request_token_payload: dict) -> dict:
# Microsoft OAuth
try:
res = cls.ms_request("https://login.live.com/oauth20_token.srf", request_token_payload, payload_url_encoded=True)
except HttpError as error:
raise OutdatedTokenError(error.res.text())
ms_refresh_token = res.get("refresh_token")
# Xbox Live Token
res = cls.ms_request("https://user.auth.xboxlive.com/user/authenticate", {
"Properties": {
"AuthMethod": "RPS",
"SiteName": "user.auth.xboxlive.com",
"RpsTicket": "d={}".format(res["access_token"])
},
"RelyingParty": "http://auth.xboxlive.com",
"TokenType": "JWT"
})
xbl_token = res["Token"]
xbl_user_hash = res["DisplayClaims"]["xui"][0]["uhs"]
# Xbox Live XSTS Token
res = cls.ms_request("https://xsts.auth.xboxlive.com/xsts/authorize", {
"Properties": {
"SandboxId": "RETAIL",
"UserTokens": [xbl_token]
},
"RelyingParty": "rp://api.minecraftservices.com/",
"TokenType": "JWT"
})
xsts_token = res["Token"]
if xbl_user_hash != res["DisplayClaims"]["xui"][0]["uhs"]:
raise AuthError("inconsistent user hash")
# MC Services Auth
res = cls.ms_request("https://api.minecraftservices.com/authentication/login_with_xbox", {
"identityToken": f"XBL3.0 x={xbl_user_hash};{xsts_token}"
})
mc_access_token = res["access_token"]
# MC Services Profile
try:
res = cls.mc_request_profile(mc_access_token)
except HttpError as error:
if error.res.status == 404:
raise DoesNotOwnMinecraftError(error.res.text())
elif error.res.status == 401:
raise OutdatedTokenError(error.res.text())
else:
res = error.res.json()
raise AuthError(res.get("errorMessage", res.get("error", "unknown error")))
return {
"refresh_token": ms_refresh_token,
"access_token": mc_access_token,
"username": res["name"],
"uuid": res["id"]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants