Skip to main content

Module oauth

Module oauth 

Source
Expand description

OAuth 2.0 authentication support for LLM providers

This module provides OAuth authentication support for various LLM providers, starting with Anthropic Claude Pro/Max subscriptions.

§Architecture

  • config: OAuth configuration types
  • error: Error types for OAuth operations
  • flow: OAuth 2.0 authorization code flow implementation
  • pkce: PKCE (Proof Key for Code Exchange) implementation
  • provider: OAuth provider trait and types
  • providers: Concrete provider implementations
  • registry: Provider registry for managing providers

§Example

use stakpak_shared::oauth::{OAuthFlow, ProviderRegistry};

// Get the Anthropic provider
let registry = ProviderRegistry::new();
let provider = registry.get("anthropic").unwrap();

// Get OAuth config for Claude Pro/Max
let config = provider.oauth_config("claude-max").unwrap();

// Start the OAuth flow
let mut flow = OAuthFlow::new(config);
let auth_url = flow.generate_auth_url();

// User visits auth_url, gets code, then:
// let tokens = flow.exchange_code(code).await?;
// let auth = provider.post_authorize("claude-max", &tokens).await?;

Re-exports§

pub use config::OAuthConfig;
pub use error::OAuthError;
pub use error::OAuthResult;
pub use flow::OAuthFlow;
pub use flow::TokenResponse;
pub use pkce::PkceChallenge;
pub use provider::AuthMethod;
pub use provider::AuthMethodType;
pub use provider::OAuthProvider;
pub use providers::AnthropicProvider;
pub use registry::ProviderRegistry;

Modules§

config
OAuth configuration types
error
OAuth error types
flow
OAuth 2.0 authorization code flow implementation
pkce
PKCE (Proof Key for Code Exchange) implementation
provider
OAuth provider trait and authentication method types
providers
OAuth provider implementations
registry
OAuth provider registry