Files
better-auth/docs/content
Gustavo Valverde 9ceb4c0246 feat(oauth-provider): extensible grant types, metadata, and token claims
Open the oauth-provider for plugin-based extension via the Plugin
Extension Protocol.

OAuthProviderExtension contract (5 extension points):
- grantTypes: register custom grant type handlers on the token endpoint
- grantTypeURIs: add to allowlist and grant_types_supported metadata
- metadata: contribute fields to discovery endpoints
- tokenClaims: inject claims into access tokens and ID tokens
- tokenEndpointAuthMethods: advertise additional auth methods

Token endpoint:
- Body schema: z.enum() → z.string().trim().min(1) + .passthrough()
- Switch default: dispatches to extension-contributed grant handlers
- GrantType union widened with (string & {}) for custom URIs

Exported utilities for grant handler authors:
- createUserTokens, checkResource, validateClientCredentials,
  basicToClientCredentials, getClient, storeToken, getStoredToken
- Types: GrantTypeHandler, OAuthProviderExtension, TokenClaimInfo

Docs:
- New guide: extending-plugins.mdx (full authoring reference)
- Updated oauth-provider docs with extension points section
- Updated plugin index with Building Plugins section
2026-03-20 01:07:06 +00:00
..