Support OpenRouter OAuth PKCE authentication #4711

Open
opened 2026-02-16 17:45:08 -05:00 by yindo · 1 comment
Owner

Originally created by @Void-n-Null on GitHub (Jan 11, 2026).

Originally assigned to: @thdxr on GitHub.

Problem

Currently, OpenRouter authentication only supports manually entering an API key. OpenRouter provides an OAuth PKCE flow that allows users to authenticate with their OpenRouter account directly, which is more convenient and aligns with how other providers (Anthropic, GitHub Copilot, OpenAI/Codex) handle authentication.

Proposed Solution

Add an internal authentication plugin for OpenRouter that implements the OAuth PKCE flow, following the same pattern as the existing CodexAuthPlugin.

The flow:

  1. Start a local HTTP server to receive the OAuth callback
  2. Open browser to OpenRouter authorization URL with PKCE challenge
  3. User authorizes in browser
  4. Exchange authorization code for API key
  5. Store the API key

Reference: https://openrouter.ai/docs/guides/overview/auth/oauth

Additional Context

This falls under "Support for new providers" in the contributing guidelines. The implementation follows established patterns in the codebase and requires minimal changes to existing files.

Originally created by @Void-n-Null on GitHub (Jan 11, 2026). Originally assigned to: @thdxr on GitHub. ## Problem Currently, OpenRouter authentication only supports manually entering an API key. OpenRouter provides an OAuth PKCE flow that allows users to authenticate with their OpenRouter account directly, which is more convenient and aligns with how other providers (Anthropic, GitHub Copilot, OpenAI/Codex) handle authentication. ## Proposed Solution Add an internal authentication plugin for OpenRouter that implements the OAuth PKCE flow, following the same pattern as the existing `CodexAuthPlugin`. The flow: 1. Start a local HTTP server to receive the OAuth callback 2. Open browser to OpenRouter authorization URL with PKCE challenge 3. User authorizes in browser 4. Exchange authorization code for API key 5. Store the API key Reference: https://openrouter.ai/docs/guides/overview/auth/oauth ## Additional Context This falls under "Support for new providers" in the contributing guidelines. The implementation follows established patterns in the codebase and requires minimal changes to existing files.
Author
Owner

@github-actions[bot] commented on GitHub (Jan 11, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #5668: [FEATURE]: OpenRouter OAuth support

Feel free to ignore if this addresses a different aspect of OpenRouter authentication.

@github-actions[bot] commented on GitHub (Jan 11, 2026): This issue might be a duplicate of existing issues. Please check: - #5668: [FEATURE]: OpenRouter OAuth support Feel free to ignore if this addresses a different aspect of OpenRouter authentication.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4711