mecha10-auth 0.1.46

Authentication services for Mecha10 - shared between CLI and launcher
Documentation

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();

    // Run device code flow
    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?;

    // Save credentials
    credentials_service.save(&credentials)?;
    Ok(())
}