Skip to main content
customProvider builds a complete OAuthConfig from an identity provider’s OAuth discovery document: it reads the provider’s metadata at boot and verifies access tokens against its JWKS. Reach for it when no branded provider fits, for any IdP that publishes discovery metadata and signs JWT access tokens.

Example

server.ts
customProvider fetches https://auth.myshop.com’s discovery document when the app starts, then the oauth field mounts the well-known metadata and JWKS bearer verification on /mcp. audience is the value the IdP binds into the token’s aud claim, here this server’s public URL.

Signature

Parameters

opts

Returns

An OAuthProvider: a deferred OAuthConfig you pass to the oauth field. Discovery is a network call, so it runs in resolve() at run(), not when your module is imported. Call resolve() yourself when wiring requireBearerAuth by hand.
TExtra is the claim shape the verifier resolves with, and the server reads it from here, so handlers get extra.http?.authInfo?.extra typed without declaring anything. Pass it as a type argument to name claims your IdP sends: customProvider<{ subject?: string; email?: string }>({ ... }). Build this object by hand only to wire an IdP whose metadata customProvider can’t discover. Supply a verifier, from createJwksVerifier({ issuer, jwksUri }) for JWTs or your own TokenVerifier for opaque tokens. Either way the oauth field mounts the same endpoints.

Connect an Identity Provider

Set up sign-in with a hosted provider

Authenticate Users

Add sign-in to your app end to end

Skybridge

Pass the config to the oauth field