mojang.api.auth.microsoft

mojang.api.auth.microsoft.authenticate_minecraft(userhash: str, xsts_token: str) str

Retrieve the Minecraft access token loging in using Xbox Live

Parameters:
  • userhash (str) – The user hash from Xbox Live

  • xsts_token (str) – The XSTS Token from Xbox Live

Returns:

The minecraft token

Raises:
  • XboxLiveInvalidUserHash – if the user hash is invalid

  • Unauthorized – if the XSTS token is invalid

Example:

>>> from mojang.account.auth import microsoft
>>> ACCESS_TOKEN = "...."  # Access token from Microsoft
>>> xbl_token, _ = microsoft.authenticate_xbl(ACCESS_TOKEN)
>>> xsts_token, userhash = microsoft.authenticate_xsts(xbl_token)
>>> mc_access_token = microsoft.authenticate_minecraft(userhash, xsts_token)
mojang.api.auth.microsoft.authenticate_xbl(auth_token: str) tuple[str, str]

Authenticate with Xbox Live using the Microsoft access token received after the OAuth authentication

Parameters:

auth_token (str) – The access token

Returns:

A tuple with the Xbox Live token and user hash

Raises:

XboxLiveAuthenticationError – if the auth token is invalid

mojang.api.auth.microsoft.authenticate_xsts(xbl_token: str) tuple[str, str]

Retrieve the XSTS Token using the Xbox Live token

Params str xbl_token:

The Xbox Live token

Returns:

A tuple with the XSTS token and user hash

Raises:

XboxLiveAuthenticationError – if xbl is invalid