Oauth API (TypeScript)

Methods, examples, and parameters for client.oauth.

Module Overview

Create OAuth clients and exchange authorization codes for scoped access tokens.

Available Methods

  • client.oauth.clients.create() - Create OAuth client credentials.
  • client.oauth.authorizeUrl() - Generate user authorization URL.
  • client.oauth.tokens.exchange() - Exchange code for access token.

Examples

TypeScript
import { TheRouter.ai } from "@therouter/sdk";

const client = new TheRouter.ai({ apiKey: process.env.THEROUTER_API_KEY! });

const url = client.oauth.authorizeUrl({
  client_id: process.env.THEROUTER_CLIENT_ID!,
  redirect_uri: "https://app.example.com/oauth/callback",
  scope: "responses:write models:read",
});

console.log(url);
oauth-response.json
{
  "id": "req_01HXYZ123",
  "module": "oauth",
  "status": "ok"
}

Parameter Types

NameTypeRequiredDescription
client_id
stringRequiredOAuth client identifier.
redirect_uri
stringRequiredAllowed redirect URI.
scope
stringSpace-delimited requested scopes.
SDK parity
Method signatures are aligned across SDKs so migration between TypeScript and Python stays predictable.