mirror of
https://github.com/better-auth/better-auth.git
synced 2026-10-20 20:26:55 -05:00
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