microsoft_account

microsoft_account contains functions for login with a Microsoft Account. Before using this module you need to create a Azure application. Many thanks to wiki.vg for it’s documentation of the login process. For a list of all types see microsoft_types.

get_login_url(client_id: str, redirect_uri: str) -> str
Returns the url to the website on which the user logs in.
For a more secure alternative, use get_secure_login_data()
generate_state() -> str

Generates a random state

get_secure_login_data(client_id: str, redirect_uri: str, state: Optional[str] = None) -> Tuple[str, str, str]:
Generates the login data for a secure login with pkce and state.
Prevents Cross-Site Request Forgery attacks and authorization code injection attacks.
Returns the url to the website on which the user logs in, the state and the code verifier.
url_contains_auth_code(url: str) -> bool

Checks if the given url contains a authorization code.

get_auth_code_from_url(url: str) -> Optional[str]
Get the authorization code from the url.
If you want to check the state, use parse_auth_code_url(), which throws errors instead of returning an optional value.
Returns the auth code or None if the the code is nonexistent.
parse_auth_code_url(url: str, state: Optional[str]) -> str:
Parse the authorization code url and checks the state if supplied.
Returns the auth code
complete_login(client_id: str, client_secret: Optional[str], redirect_uri: str, auth_code: str, code_verifier: Optional[str] = None) -> CompleteLoginResponse:

Do the complete login process. It returns the following:

{
    "id" : "The uuid",
    "name" : "The username",
    "access_token": "The acces token",
    "refresh_token": "The refresh token",
    "skins" : [{
        "id" : "6a6e65e5-76dd-4c3c-a625-162924514568",
        "state" : "ACTIVE",
        "url" : "http://textures.minecraft.net/texture/1a4af718455d4aab528e7a61f86fa25e6a369d1768dcb13f7df319a713eb810b",
        "variant" : "CLASSIC",
        "alias" : "STEVE"
    } ],
    "capes" : []
}
complete_refresh(client_id: str, client_secret: Optional[str], redirect_uri: Optional[str], refresh_token: str) -> CompleteLoginResponse:

Do the complete login process with a refresh token. It returns the same as complete_login().

get_authorization_token(client_id: str, client_secret: Optional[str], redirect_uri: str, auth_code: str, code_verifier: Optional[str]) -> AuthorizationTokenResponse:

Get the authorization token.

refresh_authorization_token(client_id: str, client_secret: Optional[str], redirect_uri: Optional[str], refresh_token: str) -> AuthorizationTokenResponse:

Refresh the authorization token.

authenticate_with_xbl(access_token: str) -> XBLResponse

Authenticate with Xbox Live.

authenticate_with_xsts(xbl_token: str) -> XSTSResponse

Authenticate with XSTS.

authenticate_with_minecraft(userhash: str, xsts_token: str) -> MinecraftAuthenticateResponse

Authenticate with Minecraft.

get_store_information(access_token: str) -> MinecraftProfileResponse

Get the store information.

get_profile(access_token: str) -> MinecraftProfileResponse

Get the profile.