Authentication Architecture
The authentication system is built around three core classes:MinecraftAccount - Account Management
TheMinecraftAccount class represents a single account with all its associated data.
launcher/minecraft/auth/MinecraftAccount.h:77-173
Account Types
Two account types are supported:Microsoft Account (MSA)
Microsoft Account (MSA)
Full authentication with Microsoft’s identity platform:
- Requires OAuth2 browser authentication
- Validates Minecraft ownership
- Provides profile information and skins
- Supports multiplayer and realms
Offline Account
Offline Account
Local-only accounts without authentication:
- No server connectivity
- No skin support
- No multiplayer (except LAN)
- Useful for modded/offline play
Account Storage
Accounts are persisted to JSON:- Account type and internal ID
- MSA tokens (access, refresh)
- Xbox Live tokens (user, XSTS)
- Minecraft tokens
- Profile information (UUID, name)
- Skin data
- Entitlement status
Tokens are stored encrypted where platform support is available (e.g., Windows Credential Manager, macOS Keychain).
AuthFlow - Multi-Step Authentication
TheAuthFlow class orchestrates the complete authentication process as a sequence of steps.
launcher/minecraft/auth/AuthFlow.h:12-46
Authentication Flow States
launcher/minecraft/auth/AuthStep.h:12-21
Authentication Steps
Microsoft Account Login Flow
For MSA accounts, authentication involves 7 sequential steps:1. MSA Step - OAuth2 Authorization
launcher/minecraft/auth/steps/MSAStep.h:42-59
This step:
- Opens browser for user consent
- Obtains Microsoft access token
- Handles OAuth2 callback
- Client ID (from Prism Launcher registration)
- Scopes:
XboxLive.signinandXboxLive.offline_access - Redirect URI for OAuth callback
Device Code Flow: For headless systems or when browser access is limited, an alternative device code flow is available:This provides a code the user enters on another device.
2. Xbox User Step - Xbox Live User Token
Converts MSA token to Xbox Live user token:- Calls Xbox Live authentication service
- Obtains user hash (uhs)
- Gets Xbox user token
3. Xbox Authorization Step - Xbox Live XSTS Token
Obtains Xbox Live Security Token Service (XSTS) token:- Uses Xbox user token
- Requests “rp://api.minecraftservices.com/” as relying party
- Gets XSTS token and user claims
This step can fail with specific errors:
2148916233- Account doesn’t have an Xbox account2148916235- Xbox Live not available in user’s region2148916236- Adult verification required2148916238- Account is a child without parental consent
4. Launcher Login Step - Minecraft Token
Exchanges Xbox Live tokens for Minecraft access token:- Minecraft access token
- Token expiration time
5. Entitlements Step - Ownership Check
Verifies the account owns Minecraft:game_minecraftentitlement (Java Edition)product_minecraftentitlement (older format)
ownsMinecraft flag in account data.
6. Profile Step - Minecraft Profile
Fetches the Minecraft profile (UUID and username):7. Get Skin Step - Download Skin
Downloads the player’s skin texture:- Parses skin URL from profile
- Downloads skin image
- Caches for avatar display
Authentication Sequence Diagram
AuthStep - Base Class
All authentication steps inherit fromAuthStep:
launcher/minecraft/auth/AuthStep.h:23-44
Each step:
- Performs its authentication operation
- Updates
AccountDatawith new tokens/information - Emits
finished()with success/failure state - AuthFlow automatically proceeds to next step on success
AccountList - Account Management
TheAccountList class manages the collection of all accounts:
launcher/minecraft/auth/AccountList.h:50-173
Automatic Token Refresh
The account list automatically refreshes expiring tokens:- Checks all accounts for expiring tokens
- Queues refresh operations
- Processes one refresh at a time
- Updates account status on completion
Refresh Priority
Refresh Priority
Session Management
When launching an instance, anAuthSession is created from the account:
Security Considerations
Token Storage
- Tokens stored in platform-specific secure storage when available
- Fallback to obfuscated JSON storage
- File permissions restricted (chmod 600)
Token Lifetime
- MSA Tokens - Short-lived access tokens (~1 hour), long-lived refresh tokens (~90 days)
- Xbox Tokens - Temporary tokens (~24 hours)
- Minecraft Tokens - Session tokens (~24 hours)
Refresh tokens can be invalidated by:
- Password changes
- Security incidents
- Explicit revocation by user
- Prolonged inactivity (90+ days)
Client ID
Prism Launcher uses its own registered Microsoft Azure AD application:- Identify the application to Microsoft
- Request appropriate scopes
- Comply with Microsoft authentication policies
Error Handling
Authentication errors are categorized:Soft Failures
- Token refresh fails but cached data still valid
- Can still launch in offline mode
- User should re-authenticate when possible
Hard Failures
- All tokens invalid
- Must re-authenticate to launch
- Account marked as “offline”
Account Gone
- Account deleted or banned
- Cannot be recovered
- Should be removed from account list
UI Integration
The authentication UI provides:- Account List Dialog - Manage accounts, add/remove, set default
- Browser Integration - Open system browser for OAuth
- Progress Dialogs - Show authentication step progress
- Error Dialogs - Display specific error messages
Account Selection at Launch
When launching an instance:- Uses instance-specific account if set
- Falls back to global default account
- Checks if account needs refresh
- Prompts for re-authentication if needed
- Creates auth session for launch
Offline Mode
When authentication fails or no account is available:- Generate deterministic UUID from username
- No server authentication
- Local-only gameplay
- Compatible with LAN multiplayer
Future Considerations
- Microsoft Account Profiles - Multiple profiles per account (not yet implemented by Mojang)
- Cape Support - Enhanced cape display and selection
- Skin Upload - Direct skin upload through launcher
