Skip to main content
Implement OAuthProvider from @hookfish/provider when a service is not built in. The provider owns the upstream protocol details; Hookfish owns state, storage, encryption, resource authorization, and connection lifecycle.

Required operations

Every provider must create an authorization request and exchange the returned code.
The helper functions in this example belong to your provider package. Keep client authentication, request encoding, response validation, PKCE generation, and error translation inside that package.

Optional capabilities

Implement refreshToken when the provider issues refresh tokens. Implement revokeToken when it exposes a revocation API. Hookfish reports these capabilities in provider discovery and invokes them at the appropriate point in the connection lifecycle. Implement isConfigured when provider availability depends on credentials. Return false instead of failing the complete provider listing.

Make a reusable template

Implement OAuthProviderTemplate when operators should create dynamic instances. A template can validate non-secret configuration, replace credentials, and optionally register OAuth clients.
Validate every upstream JSON response before returning it. Throw ProviderConfigurationError for invalid local configuration and ProviderRequestError for upstream failures.