9 releases (5 breaking)
0.6.1 | Mar 15, 2020 |
---|---|
0.6.0 | Mar 15, 2020 |
0.5.1 | Feb 29, 2020 |
0.4.0 | Oct 9, 2019 |
0.1.0 | Jul 2, 2019 |
#6 in #mojang
19KB
270 lines
mojang-api
This crate offers a simple interface for utilizing the Mojang API. It utilizes experimental async/await syntax, allowing for clean, asynchronous requests.
Currently, the following mechanisms are supported:
- Obtaining the "server hash" required for authenticating with Mojang.
- Running server-side authentication of a client.
In the future, additional functionality will be added.
lib.rs
:
A simple, easy-to-use library for interfacing with the Mojang API.
All functions involving IO in this crate are asynchronous and utilize async/await. As a result, you will have to use nightly Rust until async/await is stabilized.
This crate provides a number of functions:
- Server-side authentication with the Mojang API, used to verify
that clients have logged in correctly. This is available using the
server_auth
function. - Obtaining the "server hash" required for authentication, available using
server_hash
. Since Mojang uses abnormal hash digests for obtaining the value, this crate provides a simple way to obtain it.
Examples
Authenticating a client on a server:
// Obtain the "server hash"
let server_hash = mojang_api::server_hash(
"", // Note that the "server ID" is always an empty string
shared_secret,
public_key,
);
// Make the API request
let response = mojang_api::server_auth(&server_hash, username).await?;
// Now do something with it...
Dependencies
~4–8.5MB
~194K SLoC