Skip to main content

Overview

Authentication commands handle both Minecraft account authentication (Microsoft and Offline) and LiquidBounce account authentication. These commands are defined in src-tauri/src/app/gui/commands/auth.rs.

Minecraft Authentication

login_offline

Create an offline Minecraft account with a username. This generates a UUID using the same algorithm as Minecraft servers.
#[tauri::command]
pub(crate) async fn login_offline(username: &str) -> Result<MinecraftAccount, String>
username
string
required
The Minecraft username for the offline account. Can be any string.
MinecraftAccount
object
An offline Minecraft account object
The UUID generation algorithm matches Minecraft’s offline mode:
// Generates UUID from "OfflinePlayer:$name"
let name_str = format!("OfflinePlayer:{}", username);
let bytes = name_str.as_bytes();
let uuid = UUID::v3_from_md5(bytes);

login_microsoft

Authenticate with a Microsoft account to create a premium Minecraft account. This initiates the Microsoft device code flow.
#[tauri::command]
pub(crate) async fn login_microsoft(window: Window) -> Result<MinecraftAccount, String>
window
Window
required
The Tauri window instance (automatically passed by Tauri)
MinecraftAccount
object
A premium Microsoft-authenticated Minecraft account
This command will block until the user completes authentication. Listen for the microsoft_code event to display the device code to the user.
Events:
  • microsoft_code - Emitted with the device code string that the user needs to enter at microsoft.com/devicelogin

refresh

Refresh the authentication tokens for a Microsoft account. This checks if tokens are expired and renews them if necessary.
#[tauri::command]
pub(crate) async fn refresh(account_data: MinecraftAccount) -> Result<MinecraftAccount, String>
account_data
MinecraftAccount
required
The Minecraft account to refresh. Can be any type, but only Microsoft accounts are actually refreshed.
MinecraftAccount
object
The refreshed account with updated tokens
  • For Premium accounts: Refreshes Microsoft, Xbox Live, and Minecraft tokens if expired
  • For LegacyMsa accounts: Refreshes and upgrades to Premium format
  • For Offline accounts: Returns the account unchanged

logout

Logout from a Minecraft account. Currently performs cleanup operations.
#[tauri::command]
pub(crate) async fn logout(account_data: MinecraftAccount) -> Result<(), String>
account_data
MinecraftAccount
required
The Minecraft account to logout from
result
void
Returns nothing on success

LiquidBounce Authentication

client_account_authenticate

Authenticate with a LiquidBounce account using OAuth2 flow.
#[tauri::command]
pub(crate) async fn client_account_authenticate(client: Client) -> Result<ClientAccount, String>
client
Client
required
The LiquidBounce API client instance
ClientAccount
object
The authenticated LiquidBounce account with user information
This command automatically opens the OAuth2 authorization URL in the user’s default browser.

client_account_update

Update and refresh a LiquidBounce account’s access token and user information.
#[tauri::command]
pub(crate) async fn client_account_update(
    client: Client,
    account: ClientAccount
) -> Result<ClientAccount, String>
client
Client
required
The LiquidBounce API client instance
account
ClientAccount
required
The current LiquidBounce account to update
ClientAccount
object
The updated account with fresh tokens and user information
This command performs two operations:
  1. Renews the OAuth2 access token using the refresh token
  2. Fetches updated user information from the API

Error Handling

All authentication commands return Result<T, String>, which means they can fail with descriptive error messages:
try {
  const account = await invoke('login_microsoft');
} catch (error) {
  // error is a string like:
  // "unable to refresh: <reason>"
  // "unable to fetch user information: <reason>"
  // "unable to logout: <reason>"
  console.error('Authentication failed:', error);
}

Source Code

Location: src-tauri/src/app/gui/commands/auth.rs:1 Key dependencies:
  • azalea_auth - Microsoft authentication library
  • crate::auth::ClientAccount - LiquidBounce account types
  • crate::minecraft::auth::MinecraftAccount - Minecraft account types

Build docs developers (and LLMs) love