[−][src]Crate mojang_api
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...
Structs
ClientLoginResponse | Represents the response received from the client authentication endpoint. |
ProfileProperty | Represents a profile property returned in the server authentication request. |
SelectedProfile | Information about a user's profile, including their name, UUID, etc. Similar to |
ServerAuthResponse | Represents the response received when performing server-side authentication with the Mojang API. |
User | Information about a user, including UUID, email, username, etc. |
Enums
Error | Error type for this crate. |
Functions
client_auth | Performs client-side authentication with the given access token and server hash. |
client_login | Authenticates a user, returning a client access token and metadata for the user. |
hexdigest | Generates a digest for the given hasher using Minecraft's unorthodox hex digestion method. |
server_auth | Performs server-side authentication using the given server hash and username. |
server_hash | Computes the "server hash" required for authentication based on the server ID, the shared secret used for communication with the client, and the server's public RSA key. |
Type Definitions
Result | Result type used by this crate. This is equivalent
to |