Skip to content

ccproxy.plugins.oauth_claude.plugin

ccproxy.plugins.oauth_claude.plugin

OAuth Claude plugin v2 implementation.

OAuthClaudeRuntime

OAuthClaudeRuntime(manifest)

Bases: AuthProviderPluginRuntime

Runtime for OAuth Claude plugin.

Source code in ccproxy/plugins/oauth_claude/plugin.py
def __init__(self, manifest: PluginManifest):
    """Initialize runtime."""
    super().__init__(manifest)
    self.config: ClaudeOAuthConfig | None = None

OAuthClaudeFactory

OAuthClaudeFactory()

Bases: AuthProviderPluginFactory

Factory for OAuth Claude plugin.

Source code in ccproxy/plugins/oauth_claude/plugin.py
def __init__(self) -> None:
    """Initialize factory with manifest."""
    # Create manifest with static declarations
    manifest = PluginManifest(
        name="oauth_claude",
        version="0.1.0",
        description="Standalone Claude OAuth authentication provider plugin",
        is_provider=True,  # It's a provider plugin but focused on OAuth
        config_class=ClaudeOAuthConfig,
        dependencies=[],
        routes=[],  # No HTTP routes needed
        tasks=[],  # No scheduled tasks needed
    )

    # Initialize with manifest
    super().__init__(manifest)

create_context

create_context(core_services)

Create context with auth provider components.

Parameters:

Name Type Description Default
core_services Any

Core services container

required

Returns:

Type Description
PluginContext

Plugin context with auth provider components

Source code in ccproxy/plugins/oauth_claude/plugin.py
def create_context(self, core_services: Any) -> PluginContext:
    """Create context with auth provider components.

    Args:
        core_services: Core services container

    Returns:
        Plugin context with auth provider components
    """
    # Start with base context
    context = super().create_context(core_services)

    # Create auth provider for this plugin
    auth_provider = self.create_auth_provider(context)
    context["auth_provider"] = auth_provider

    # Add other auth-specific components if needed
    storage = self.create_storage()
    if storage:
        context["storage"] = storage

    return context

create_runtime

create_runtime()

Create runtime instance.

Source code in ccproxy/plugins/oauth_claude/plugin.py
def create_runtime(self) -> OAuthClaudeRuntime:
    """Create runtime instance."""
    return OAuthClaudeRuntime(self.manifest)

create_auth_provider

create_auth_provider(context=None)

Create OAuth provider instance.

Parameters:

Name Type Description Default
context PluginContext | None

Plugin context containing shared resources

None

Returns:

Type Description
OAuthProviderProtocol

ClaudeOAuthProvider instance

Source code in ccproxy/plugins/oauth_claude/plugin.py
def create_auth_provider(
    self, context: PluginContext | None = None
) -> OAuthProviderProtocol:
    """Create OAuth provider instance.

    Args:
        context: Plugin context containing shared resources

    Returns:
        ClaudeOAuthProvider instance
    """
    # Prefer validated config from context when available
    if context and isinstance(context.get("config"), ClaudeOAuthConfig):
        cfg = cast(ClaudeOAuthConfig, context.get("config"))
    else:
        cfg = ClaudeOAuthConfig()
    config: ClaudeOAuthConfig = cfg
    http_client = context.get("http_client") if context else None
    hook_manager = context.get("hook_manager") if context else None
    # CLIDetectionService is injected under 'cli_detection_service' in base context
    detection_service = context.get("cli_detection_service") if context else None
    settings = context.get("settings") if context else None
    provider = ClaudeOAuthProvider(
        config,
        http_client=http_client,
        hook_manager=hook_manager,
        detection_service=detection_service,
        settings=settings,
    )
    return cast(OAuthProviderProtocol, provider)

create_storage

create_storage()

Create storage for OAuth credentials.

Returns:

Type Description
Any | None

Storage instance or None to use provider's default

Source code in ccproxy/plugins/oauth_claude/plugin.py
def create_storage(self) -> Any | None:
    """Create storage for OAuth credentials.

    Returns:
        Storage instance or None to use provider's default
    """
    # ClaudeOAuthProvider manages its own storage internally
    return None