Mecha10 Authentication Library
Shared authentication services for CLI and launcher.
Features
- Device code OAuth 2.0 flow (RFC 8628) for browser-based authentication
- Credentials storage at ~/.mecha10/credentials.json
- Support for custom auth server URLs via MECHA10_AUTH_URL environment variable
Usage
use mecha10_auth::{AuthService, CredentialsService};
async fn login() -> anyhow::Result<()> {
let auth_service = AuthService::new();
let credentials_service = CredentialsService::new();
let credentials = auth_service.run_device_code_flow(|device_code| {
println!("Go to: {}", device_code.verification_uri);
println!("Enter code: {}", device_code.user_code);
}).await?;
credentials_service.save(&credentials)?;
Ok(())
}