openrouter-oauth
Implement "Sign In with OpenRouter" using OAuth PKCE — framework-agnostic, no SDK or client registration required.
Skill by clawdsolana
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/clawdsolana-openrouter-oauth
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: backend, ml, security
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/openrouter-oauth
What's inside
- Skill name
openrouter-oauth- Description
- Implement "Sign In with OpenRouter" using OAuth PKCE — framework-agnostic, no SDK or client registration required. Use when the user wants to add OpenRouter login, authentication, sign-in buttons, OAuth, or AI model inference API keys for browser-based apps. No client registration, no backend, no secrets required.
- License
- MIT
- Compatibility
- browser (requires Web Crypto API, localStorage, sessionStorage)
- Instructions
- 217 lines in SKILL.md · view on GitHub
Before installing
- Instructions call the network
Files (1)
- SKILL.md
SKILL.md (first lines)
# Sign In with OpenRouter
Add OAuth login to any web app. Users authorize on OpenRouter and your app receives an API key — no client registration, no backend, no secrets. Works with any framework.
Live demo: [openrouterteam.github.io/sign-in-with-openrouter](https://openrouterteam.github.io/sign-in-with-openrouter/)
## Decision Tree
| User wants to… | Do this |
|---|---|
| Add sign-in / login to a web app | Follow the full PKCE flow + button guidance below |
| Get an API key programmatically (no UI) | Just implement the PKCE flow — skip the button section |
| Use the OpenRouter SDK after auth | Do PKCE here for the key, then see `openrouter-typescript-sdk` skill for `callModel`/streaming |
---
## OAuth PKCE Flow
No client ID or secret — the PKCE challenge is the only proof of identity.
### Step 1: Generate verifier and challenge
```
code_verifier = base64url(32 random bytes)
code_challenge = base64url(SHA-256(code_verifier))
```
- Use `crypto.getRandomValues(new Uint8Array(32))` for the random bytes
- base64url encoding: standard base64, then replace `+` → `-`, `/` → `_`, strip trailing `=`
- Store `code_verifier` in **`sessionStorage`** (not `localStorage`) — so the verifier doesn't persist after the tab closes or leak to other tabs (security: the verifier is a one-time secret)
### Step 2: Redirect to OpenRouter
```
https://openrouter.ai/auth?callback_url={url}&code_challenge={challenge}&code_challenge_method=S256
```
| Param | Value |
|---|---|
| `callback_url` | Your app's URL (where the user returns after auth) |
| `code_challenge` | The S256 challenge from Step 1 |
| `code_challenge_method` | Always `S256` |
### Step 3: Handle the redirect back
User returns to your `callback_url` with `?code=` appended. Extract the `code` query parameter.
**Important:** Before processing `?code=`, check that a `code_verifier` exists in `sessionStorage`. Other routes or third-party code might use `?code=` query params for unrelated purposes — a `hasOAuthCallbackPending()` guard ensures you only consume codes that belong to your OAuth flow.
### Step 4: Exchange code for API key
```
POST https://openrouter.ai/api/v1/auth/keys
Content-Type: application/json
{
"code": "<code from query param>",
"code_verifier": "<verifier from sessionStorage>",
"code_challenge_method": "S256"
}
→ { "key": "sk-or-..." }
```
Remove the verifier from `sessionStorage` before or after the exchange.
### Step 5: Store the key and clean up
- Store `key` in `localStorage`
- Clean the URL: `history.replaceState({}, "", location.pathname)` to remove `?code=`
- **Cross-tab sync:** Listen for `storage` events on the API key's `localStorage` entry so other tabs update when the user signs in or out
---
## Auth Module Reference
Drop-in module implementing the full PKCE flow. Reduces risk of getting base64url encoding, sessionStorage handling, or the key exchange wrong.
```typescript
// lib/openrouter-auth.ts
const STORAGE_KEY = "openrouter_api_key";
const VERIFIER_KEY = "openrouter_code_verifier";
type AuthListener = () => void;
const listeners = new Set<AuthListener>();
export const onAuthChange = (fn: AuthListener) => { listeners.add(fn); return () => listeners.delete(fn); };
const notify = () => listeners.forEach((fn) => fn());
// Cross-tab sync: other tabs update when user signs in/out
if (typeof window !== "undefined") {
window.addEventListener("storage", (e) => { if (e.key === STORAGE_KEY) notify(); });
}
export const getApiKey = (): string | null =>
typeof window !== "undefined" ? localStorage.getItem(STORAGE_KEY) : null;
export const setApiKey = (key: string) => { localStorage.setItem(STORAGE_KEY, key); notify(); };
export const clearApiKey = () => { localStorage.removeItem(STORAGE_KEY); notify(); };
// Guard: only process ?code= if we initiated an OAuth flow in this tab
export const hasOAuthCallbackPending = (): boolean =>
typeof window !== "undefined" && sessionStorage.getItem(VERIFIER_KEY) !== null;
function generateCodeVerifier(): string {
const bytes = new Uint8Array(32);
crypto.getRandomValues(bytes);
return btoa(String.fromCharCode(...bytes))
.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
}
async function computeS256Challenge(verifier: string): Promise<string> {
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(verifier));
return btoa(String.fromCharCode(...new Uint8Array(digest)))
.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
}
export async function initiateOAuth(callbackUrl?: string): Promise<void> {
const verifier = generateCodeVerifier();
sessionStorage.setItem(VERIFIER_KEY, verifier);From clawdsolana/OpenClawd, MIT.
More from clawdsolana/OpenClawd
- 0.512score
openrouter-images
clawdsolana
Generate images from text prompts and edit existing images using OpenRouter's image generation models.
SkillCFreshness: C★ 2Claude Code +9 - 0.512score
pay
clawdsolana
User-authorized paid HTTP/API access for agents through local Pay MCP and TouchID gated payments (x402 MPP HTTP 402) SERVICES: search web, scrape, enrich…
SkillCFreshness: C★ 2Claude Code +9 - 0.512score
openrouter-models
clawdsolana
Query OpenRouter for available AI models, pricing, capabilities, throughput, and provider performance.
SkillCFreshness: C★ 2Claude Code +9 - 0.507score
honcho-cli
clawdsolana
Inspect and debug Honcho workspaces via the `honcho` CLI.
SkillCFreshness: C★ 2Claude Code +9 - 0.507score
migrate-honcho-ts
clawdsolana
Migrates Honcho TypeScript SDK code from v1.6.0 to v2.1.1.
SkillCFreshness: C★ 2Claude Code +9 - 0.504score
crossmint-agentic-wallet
clawdsolana
Create non-custodial Solana wallets for AI agents with e-commerce, Jupiter swaps, faucet funding, and agent-to-agent payments
SkillCFreshness: C★ 2Claude Code +9 - 0.504score
openrouter-agent-migration
clawdsolana
Migration guide from @openrouter/sdk to @openrouter/agent for callModel, tool(), stop conditions, and agent features.
SkillCFreshness: C★ 2Claude Code +9 - 0.503score
create-agent-tui
clawdsolana
Scaffolds a complete agent TUI in TypeScript using @openrouter/agent — like create-react-app for terminal agents.
SkillCFreshness: C★ 2Claude Code +9 - 0.503score
honcho-memory
plastic-labs
Gives AI agents persistent memory across conversations using Honcho.
SkillCFreshness: C★ 2Claude Code +9 - 0.503score
migrate-honcho
clawdsolana
Migrates Honcho Python SDK code from v1.6.0 to v2.1.1.
SkillCFreshness: C★ 2Claude Code +9 - 0.501score
competitive-analysis
clawdsolana
Perform competitive market analysis with comparisons and strategic recommendations.
SkillCFreshness: C★ 2Claude Code +9 - 0.501score
branding-generator
clawdsolana
Create brand identity kits — logos, color palettes, typography, naming, and style guides.
SkillCFreshness: C★ 2Claude Code +9
Signals
- Stars
- 2
- Forks
- 3
- Open issues
- 2
- Last commit (this folder)
- May 7, 2026 (5 months ago)
- Last release
- Apr 30, 2026 (6 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/clawdsolana/OpenClawd
- Website
- solanaclawd.com/openclawd
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
More from clawdsolana
- 0.512score
openrouter-models
clawdsolana
Query OpenRouter for available AI models, pricing, capabilities, throughput, and provider performance.
SkillCFreshness: C★ 2Claude Code +9 - 0.512score
pay
clawdsolana
User-authorized paid HTTP/API access for agents through local Pay MCP and TouchID gated payments (x402 MPP HTTP 402) SERVICES: search web, scrape, enrich…
SkillCFreshness: C★ 2Claude Code +9 - 0.512score
openrouter-images
clawdsolana
Generate images from text prompts and edit existing images using OpenRouter's image generation models.
SkillCFreshness: C★ 2Claude Code +9 - 0.507score
honcho-cli
clawdsolana
Inspect and debug Honcho workspaces via the `honcho` CLI.
SkillCFreshness: C★ 2Claude Code +9 - 0.507score
migrate-honcho-ts
clawdsolana
Migrates Honcho TypeScript SDK code from v1.6.0 to v2.1.1.
SkillCFreshness: C★ 2Claude Code +9 - 0.504score
openrouter-agent-migration
clawdsolana
Migration guide from @openrouter/sdk to @openrouter/agent for callModel, tool(), stop conditions, and agent features.
SkillCFreshness: C★ 2Claude Code +9
Cite this page
openrouter-oauth skill. Agent Mart. https://agentmart.dev/skills/clawdsolana-openrouter-oauth (last updated 2026-10-24)