
Security News
High Salaries No Longer Enough to Attract Top Cybersecurity Talent
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
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.
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:
Minecraft
, can also be Scrolls
True
request for user object too (default is False
)https://authserver.mojang.com
Response:
Example:
from yggdrasil import authenticate
import random
randomClientToken = random.randint(10000,99999)
mc = authenticate('test@example.com','p455w0rd', 'Minecraft', randomClientToken, False)
print(mc['accessToken'])
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:
accessToken
, gained from authenticate()
clientToken
used to get the accessToken
in the first placeTrue
request for user object too (default is False
)https://authserver.mojang.com
Response:
Example:
from yggdrasil import refresh
print(refresh(mc['accessToken'], randomClientToken))
# Note: invalidates inputted accessToken
Checks if an accessToken is usable for authentication with a Minecraft server.
def validate(accessToken:str, clientToken:str = None, authServer:str = url):
Arguments:
accessToken
, gained from authenticate()
clientToken
used to get the accessToken
in the first placehttps://authserver.mojang.com
Response:
accessToken
is valid (and clientToken
match, if defined)Example:
from yggdrasil import validate
print(validate(mc['accessToken'], randomClientToken))
Invalidates accessTokens using an account's username and password.
def signout(username:str, password:str, authServer:str = url):
Arguments:
https://authserver.mojang.com
Response:
True
unless error thrownExample:
from yggdrasil import signout
print(signout('test@example.com','p455w0rd'))
Invalidates accessTokens using a client/access token pair.
def invalidate(accessToken:str, clientToken:str, authServer:str = url):
Arguments:
accessToken
, gained from authenticate()
clientToken
used to get the accessToken
in the first placehttps://authserver.mojang.com
Response:
True
unless error thrownExample:
from yggdrasil import invalidate
print(signout(mc['accessToken'], randomClientToken))
FAQs
Python wrapper for Mojang's Yggdrasil authentication service.
We found that yggdrasil-py demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.