Multi-Runtime Support
Works seamlessly across Node.js 18+, Deno, and Bun. Write once, run anywhere with modern Web Standards APIs.
Lightweight, cross-runtime, with native MCP SDK integration for AI agents
import { getAuthCode } from "oauth-callback";
// Just pass your OAuth URL - that's it!
const result = await getAuthCode(
"https://github.com/login/oauth/authorize?client_id=xxx",
);
console.log("Auth code:", result.code);
import { browserAuth, inMemoryStore } from "oauth-callback/mcp";
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
// OAuth provider for Notion MCP server
// See: https://developers.notion.com/docs/get-started-with-mcp
const authProvider = browserAuth({
store: inMemoryStore(), // Ephemeral tokens (lost on restart)
});
// Connect to Notion's MCP server with OAuth
const transport = new StreamableHTTPClientTransport(
new URL("https://mcp.notion.com/mcp"),
{ authProvider },
);
const client = new Client(
{ name: "my-app", version: "1.0.0" },
{ capabilities: {} },
);
await client.connect(transport);
// Now you can use Notion's MCP tools!
# Using Bun (recommended)
bun add oauth-callback
# Using npm
npm install oauth-callback
# Using pnpm
pnpm add oauth-callback