Skip to main content

Module openrouter_oauth

Module openrouter_oauth 

Source
Expand description

OpenRouter OAuth PKCE authentication flow.

This module implements the OAuth PKCE flow for OpenRouter, allowing users to authenticate with their OpenRouter account securely.

§Security Model

Tokens are encrypted at rest using AES-256-GCM with a machine-derived key. The key is derived from:

  • Machine hostname
  • User ID (where available)
  • A static salt

This provides reasonable protection against casual access while remaining portable across the same user’s sessions on the same machine.

Structs§

OpenRouterOAuthConfig
Configuration for OpenRouter OAuth authentication.
OpenRouterToken
Stored OAuth token with metadata.

Enums§

AuthStatus
OAuth authentication status.

Constants§

DEFAULT_CALLBACK_PORT
Default callback port for localhost OAuth server

Functions§

clear_oauth_token
Clear the stored OAuth token.
exchange_code_for_token
Exchange an authorization code for an API key.
get_auth_status
Get the current OAuth authentication status.
get_auth_url
Generate the OAuth authorization URL.
load_oauth_token
Load an OAuth token from encrypted storage.
save_oauth_token
Save an OAuth token to encrypted storage.