vtcode-auth
vtcode-auth provides authentication and OAuth flows shared across VT Code.
It contains:
- OAuth login flows for OpenAI ChatGPT, OpenRouter, and MCP servers
- A local callback server (
axum-based) for receiving OAuth authorization codes - PKCE challenge generation for secure OAuth exchanges
- Credential storage backed by the OS keyring and on-disk fallback
Usage
Add the dependency to your Cargo.toml:
[]
= { = "../vtcode-auth" }
use ;
// Generate a PKCE challenge for an OAuth flow
let challenge = generate_pkce_challenge;
// Start the local callback server for a provider
let server = start_auth_code_callback_server.await?;
API Reference
| Type | Purpose |
|---|---|
AuthConfig |
Top-level authentication configuration |
CopilotAuthConfig |
Copilot-specific auth settings |
OpenAIAuthConfig |
OpenAI-specific auth settings |
CredentialStorage |
Read/write credentials via OS keyring or file |
CustomApiKeyStorage |
Store and retrieve user-provided API keys |
McpOAuthService |
Drive the MCP OAuth login flow |
AuthCodeCallbackServer |
Local HTTP server that captures OAuth callbacks |
OAuthProvider |
Enum of supported OAuth providers |
PkceChallenge |
PKCE code-verifier / code-challenge pair |
Public entrypoints
credentials— credential storage, migration, and custom API-key helpersmcp_oauth— MCP-server OAuth login lifecycleoauth_server— local callback server and provider definitionsopenai_chatgpt_oauth— OpenAI ChatGPT OAuth session managementopenrouter_oauth— OpenRouter OAuth token managementpkce— PKCE challenge generation