JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 19984
  • Score
    100M100P100Q142824F

Package Exports

  • poe-oauth

Readme

poe-oauth

OAuth client and API key validation for the Poe API.

OAuth

PKCE-based OAuth flow with local callback server:

import { createOAuthClient } from "poe-oauth";

const client = createOAuthClient({
  clientId: "your-client-id",
  openBrowser: async (url) => { /* open url in browser */ },
  readLine: async () => { /* read manual paste from terminal */ }
});
// Defaults to https://poe.com/oauth/authorize and https://api.poe.com/token
// Override with authorizationEndpoint / tokenEndpoint if needed

const authorization = await client.authorize();
// authorization.authorizationUrl — URL to open in browser
const result = await authorization.waitForResult();
// result.apiKey, result.expiresIn

Check auth

Verify an API key and fetch the associated identity:

import { checkAuth } from "poe-oauth";

const identity = await checkAuth({ apiKey: "sk-poe-..." });
// { email: "user@example.com", balance: 1500 } | null

API key validation

import { isValidApiKeyFormat, normalizeApiKey } from "poe-oauth";

isValidApiKeyFormat("sk-poe-abc123..."); // true
normalizeApiKey("  sk-poe-abc123...  "); // trimmed + validated