mojang.api.session¶
- mojang.api.session.change_user_name(access_token: str, name: str)¶
Change name of authenticated user
- Parameters:
- Raises:
Unauthorized – if the access token is invalid
InvalidName – if the new user name is invalid
UnavailableName – if the new user name is unavailable
- Example:
>>> from mojang.account import session >>> session.change_user_name("ACCESS_NAME", "NEW_NAME")
- mojang.api.session.change_user_skin(access_token: str, path: str, variant='classic')¶
Change skin of authenticated user
- Parameters:
- Parama str variant:
The skin variant, either classic or slim
- Raises:
Unauthorized – if the access token is invalid
- Example:
>>> from mojang.account import session >>> session.change_user_skin("ACCESS_TOKEN", "http://...")
- mojang.api.session.check_product_voucher(access_token: str, voucher: str) bool ¶
Check if a voucher is available.
- Parameters:
- Raises:
Unauthorized – if the access token is invalid
ValueError – if the voucher is not a real code
- Example:
>>> from mojang.api import session >>> session.check_product_voucher("ACCESS_TOKEN", "JHRD2-HWGTY-WP3MW-QR4MC-CGGHZ") True
- mojang.api.session.check_username(access_token: str, username: str) bool ¶
Check if username is available
Caution
This endpoint is limited, the function will return a RuntimeError if you sent too many requests.
- Parameters:
- Raises:
Unauthorized – if the access token is invalid
RuntimeError – if you sent to many requests
- mojang.api.session.get_profile(access_token: str) AuthenticatedUserProfile ¶
Returns the full profile of a authenticated user
- Parameters:
access_token (str) – The session access token
- Raises:
Unauthorized – if the access token is invalid
- mojang.api.session.get_user_name_change(access_token: str) NameChange ¶
Return if user can change name and when it was created
- Parameters:
access_token (str) – The session access token
- Raises:
Unauthorized – if the access token is invalid
- Example:
>>> from mojang.account import session >>> session.get_username_change("ACCESS_TOKEN") NameChange(allowed=True, created_at=datetime.datetime(2006, 4, 29, 10, 10, 10))
- mojang.api.session.hide_user_cape(access_token: str)¶
Hide user cape
- Parameters:
access_token (str) – The session access token
- Raises:
Unauthorized – if the access token is invalid
- Example:
>>> from mojang.account import session >>> session.hide_user_cape("ACCESS_TOKEN")
- mojang.api.session.owns_minecraft(access_token: str, verify_sig: bool = False, public_key: str | None = None) bool ¶
Returns True if the authenticated user owns minecraft
- Parameters:
- Raises:
Unauthorized – if the access token is invalid
- Example:
>>> from mojang.account import session >>> session.owns_minecraft("ACCESS_TOKEN") True
- mojang.api.session.redeem_product_voucher(access_token: str, voucher: str) bool ¶
Redeem a product voucher gift code. Returns True if the code was redeemed
- Parameters:
- Raises:
Unauthorized – if the access token is invalid
ValueError – if the voucher is not a real code
- Example:
>>> from mojang.api import session >>> session.redeem_product_voucher("ACCESS_TOKEN", "JHRD2-HWGTY-WP3MW-QR4MC-CGGHZ") True
- mojang.api.session.reset_user_skin(access_token: str)¶
Reset skin of authenticated user
- Parameters:
access_token (str) – The session access token
- Raises:
Unauthorized – if the access token is invalid
- Example:
>>> from mojang.account import session >>> session.reset_user_skin("ACCESS_TOKEN", "USER_UUID")