This repository has been archived by the owner on Apr 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7420db4
commit 8d991fe
Showing
7 changed files
with
155 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ __pycache__ | |
yggdrasil/__pycache__ | ||
.DS_Store | ||
Yggdrasil/.DS_Store | ||
dist/ | ||
dist/ | ||
Build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[metadata] | ||
description-file = README.md | ||
license_files = LICENSE.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
Metadata-Version: 2.1 | ||
Name: yggdrasil-py | ||
Version: 1.0.2 | ||
Summary: Python wrapper for Mojang's Yggdrasil authentication service. | ||
Home-page: https://github.com/samcarsonx/yggdrasil-py | ||
Author: Sam Carson | ||
Author-email: me@samcarson.xyz | ||
License: MIT | ||
Download-URL: https://github.com/samcarsonx/yggdrasil-py/archive/1.0.2.tar.gz | ||
Description: # yggdrasil-py | ||
Python 3.6+ wrapper by **Sam Carson** for the **Mojang Yggdrasil authentication service.** | ||
Please reference [the documentation](https://wiki.vg/Authentication) for extra information. | ||
|
||
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](https://wiki.vg/Legacy_Authentication "Legacy Authentication"). Mojang's other game, Scrolls, uses this method of authentication as well. | ||
|
||
## Authenticate | ||
*Authenticates a user using their password.* | ||
```python | ||
def authenticate(username:str, password:str, agentName:str = 'Minecraft', clientToken:str = None, requestUser:str = False): | ||
``` | ||
**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 be `Scrolls` | ||
* String *(optional)* | ||
Client identifier, must be random and identical per request | ||
* Boolean *(optional)* | ||
If set to `True` request for user object too (default is `False`) | ||
|
||
**Response:** | ||
* Check the Authenticate section of [the documentation](https://wiki.vg/Authentication#Authenticate) for details. | ||
|
||
**Example:** | ||
```python | ||
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.* | ||
```python | ||
def refresh(accessToken:str, clientToken:str, requestUser:bool = False): | ||
``` | ||
**Arguments:** | ||
* String *(required)* | ||
Valid `accessToken`, gained from `authenticate()` | ||
* String *(required)* | ||
Identical to the `clientToken` used to get the `accessToken` in the first place | ||
* Boolean *(optional)* | ||
If set to `True` request for user object too (default is `False`) | ||
|
||
**Response:** | ||
* Check the Refresh section of [the documentation](https://wiki.vg/Authentication#Refresh) for details. | ||
|
||
**Example:** | ||
```python | ||
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.* | ||
```python | ||
def validate(accessToken:str, clientToken:str = None): | ||
``` | ||
**Arguments:** | ||
* String *(required)* | ||
Valid `accessToken`, gained from `authenticate()` | ||
* String *(optional)* | ||
Identical to the `clientToken` used to get the `accessToken` in the first place | ||
|
||
**Response:** | ||
* Returns Boolean for whether `accessToken` is valid (and `clientToken` match, if defined) | ||
|
||
**Example:** | ||
```python | ||
from yggdrasil import validate | ||
print(validate(mc['accessToken'], randomClientToken)) | ||
``` | ||
|
||
## Signout | ||
*Invalidates accessTokens using an account's username and password.* | ||
```python | ||
def signout(username:str, password:str): | ||
``` | ||
**Arguments:** | ||
* String *(required)* | ||
Username of agent/Mojang email (if migrated) | ||
* String *(required)* | ||
Password for the account used | ||
|
||
**Response:** | ||
* Returns `True` unless error thrown | ||
|
||
**Example:** | ||
```python | ||
from yggdrasil import signout | ||
print(signout('test@example.com','p455w0rd')) | ||
``` | ||
|
||
## Invalidate | ||
*Invalidates accessTokens using a client/access token pair.* | ||
```python | ||
def invalidate(username:str, password:str): | ||
``` | ||
**Arguments:** | ||
* String *(required)* | ||
Valid `accessToken`, gained from `authenticate()` | ||
* String *(required)* | ||
Identical to the `clientToken` used to get the `accessToken` in the first place | ||
|
||
**Response:** | ||
* Returns `True` unless error thrown | ||
|
||
**Example:** | ||
```python | ||
from yggdrasil import invalidate | ||
print(signout(mc['accessToken'], randomClientToken)) | ||
``` | ||
|
||
Keywords: mojang,yggdrasil,minecraft,scrolls,authentication | ||
Platform: UNKNOWN | ||
Classifier: Development Status :: 5 - Production/Stable | ||
Classifier: Intended Audience :: Developers | ||
Classifier: Topic :: Software Development :: Build Tools | ||
Classifier: License :: OSI Approved :: MIT License | ||
Classifier: Programming Language :: Python :: 3.6 | ||
Classifier: Programming Language :: Python :: 3.7 | ||
Description-Content-Type: text/markdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
yggdrasil |