yggdrasil-py
Open-source Python 3.6+ wrapper by Sam Carson for the Mojang Yggdrasil authentication service. Please reference the documentation for extra information.
Install via PyPI using the following command: pip install yggdrasil-py
This wrapper is supported only for Python 3.6 and above because of the use of f-strings when an Exception is raised. You could easily modify the code to use %s formatting or the .format() function, but they are not as efficient.
Minecraft 1.6 introduced a new authentication scheme called Yggdrasil which completely replaces the previous authentication system. Mojang's other game, Scrolls, uses this method of authentication as well.
Since a recent pull request, support has been added for custom authentication servers. As far as I am aware, the only instance of this is ely.by.
Authenticate
Authenticates a user using their password.
def authenticate(username:str, password:str, agentName:str = 'Minecraft', clientToken:str = None, requestUser:str = False, authServer:str = url):
Arguments:
- String (required) Username of agent/Mojang email (if migrated)
- String (required) Password for the account used
- String (optional)
Agent, defaults to
Minecraft, can also beScrolls - String (optional) Client identifier, must be random and identical per request
- Boolean (optional)
If set to
Truerequest for user object too (default isFalse) - String (optional)
Custom authentication server. Defaults to
https://authserver.mojang.com
Response:
- Check the Authenticate section of the documentation for details.
Example:
from yggdrasil import authenticate
import random
randomClientToken = random.randint(10000,99999)
mc = authenticate('test@example.com','p455w0rd', 'Minecraft', randomClientToken, False)
print(mc['accessToken'])
Refresh
Refreshes a valid accessToken. It can be used to keep a user logged in between gaming sessions and is preferred over storing the user's password in a file.
def refresh(accessToken:str, clientToken:str, requestUser:bool = False, authServer:str = url):
Arguments:
- String (required)
Valid
accessToken, gained fromauthenticate() - String (required)
Identical to the
clientTokenused to get theaccessTokenin the first place - Boolean (optional)
If set to
Truerequest for user object too (default isFalse) - String (optional)
Custom authentication server. Defaults to
https://authserver.mojang.com
Response:
- Check the Refresh section of the documentation for details.
Example:
from yggdrasil import refresh
print(refresh(mc['accessToken'], randomClientToken))
# Note: invalidates inputted accessToken
Validate
Checks if an accessToken is usable for authentication with a Minecraft server.
def validate(accessToken:str, clientToken:str = None, authServer:str = url):
Arguments:
- String (required)
Valid
accessToken, gained fromauthenticate() - String (optional)
Identical to the
clientTokenused to get theaccessTokenin the first place - String (optional)
Custom authentication server. Defaults to
https://authserver.mojang.com
Response:
- Returns Boolean for whether
accessTokenis valid (andclientTokenmatch, if defined)
Example:
from yggdrasil import validate
print(validate(mc['accessToken'], randomClientToken))
Signout
Invalidates accessTokens using an account's username and password.
def signout(username:str, password:str, authServer:str = url):
Arguments:
- String (required) Username of agent/Mojang email (if migrated)
- String (required) Password for the account used
- String (optional)
Custom authentication server. Defaults to
https://authserver.mojang.com
Response:
- Returns
Trueunless error thrown
Example:
from yggdrasil import signout
print(signout('test@example.com','p455w0rd'))
Invalidate
Invalidates accessTokens using a client/access token pair.
def invalidate(accessToken:str, clientToken:str, authServer:str = url):
Arguments:
- String (required)
Valid
accessToken, gained fromauthenticate() - String (required)
Identical to the
clientTokenused to get theaccessTokenin the first place - String (optional)
Custom authentication server. Defaults to
https://authserver.mojang.com
Response:
- Returns
Trueunless error thrown
Example:
from yggdrasil import invalidate
print(signout(mc['accessToken'], randomClientToken))
Metadata
Release files for yggdrasil-py 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| yggdrasil-py-1.1.0.tar.gz | 5.0 kB | Without provenance | Details for yggdrasil-py-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| yggdrasil_py-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for yggdrasil_py-1.1.0-py3-none-any.whl |
Total release size: 12.3 kB
Release files / yggdrasil-py-1.1.0.tar.gz
| Download URL | yggdrasil-py-1.1.0.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fa898260acece495805e729836fe8c45e3962cea3278d3e49cd5e749d3e7cc83
|
|
BLAKE2b-256 checksum How to use checksums |
30d1de0d7e913fa7b483752e0954eba51669792e075ba19007efc39055de3925
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.0
|
Release files / yggdrasil_py-1.1.0-py3-none-any.whl
| Download URL | yggdrasil_py-1.1.0-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5da031fe31eecc3aac3c67d99142cd42cfdab9feb547b73ead77f733d9d85e11
|
|
BLAKE2b-256 checksum How to use checksums |
2991e4690dba53d1f8016abfb0a2467feb6d07c059c699a31fe3b74e2f97737f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.0
|
Security for yggdrasil-py 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.