Skip to main content

Function: createOAuthHandlers()

createOAuthHandlers(options): OAuthHandlers

Defined in: auth-core/src/oauthServer.ts:415

Creates runner-agnostic OAuth 2.1 Authorization Server handlers.

Implements the authorization endpoint (PKCE S256 required), token endpoint (authorization_code, plus refresh_token when onRefreshToken is set — discovery metadata and registration advertise it only then), Dynamic Client Registration (RFC 7591), and discovery metadata (RFC 8414, plus RFC 9728 when resource is set, which also enables RFC 8707 resource indicators). The handlers operate on plain OAuthRequest / OAuthResponse objects, so any HTTP runtime can host them through a thin adapter — @ttoss/http-server provides the Koa one.

The app owns its user model, signing keys, and login/consent UI through the option hooks; this core never sees them.

Parameters​

ParameterTypeDescription
optionsOAuthServerOptionsAuthorization server configuration and pluggable hooks.

Returns​

OAuthHandlers

Example​

const oauth = createOAuthHandlers({ issuer, clientStore, authCodeStore, issueTokens, onAuthorize });
const res = await oauth.token({ query: {}, body, headers });