OAuth
Sanvex shares routes and token storage across drivers. Each provider still follows its own official OAuth rules — we do not force one HTTP shape for every API.What is shared
Provider requirements (official docs)
Configure each driver’soauthConfig() to match the provider — not the other way around.
Sanvex maps these in
OAuthProviderConfig:
- Gmail:
TokenExchangeAuth::RequestBody,TokenBodyFormat::Form,authorizationParamsfor Google offline consent. - Notion:
TokenExchangeAuth::Basic,TokenBodyFormat::Json,authorizationParams: ['owner' => 'user'].
Standard URLs (when routes are enabled)
Set OAuth client id and secret in.env (see the driver’s Configuration page). Built-in routes register when the client id is set, or when auth_type is oauth_2 / oauth2.
Adding OAuth to a new driver
- Read the provider’s OAuth documentation (authorize URL, required query params, token
Content-Type, whereclient_secretgoes). - Implement
oauthConfig()with the correcttokenExchange,tokenBodyFormat, andauthorizationParams. - Add
config/{driver}.php, merge viamergeConfigFrom(..., 'sanvex.driver_configs.{id}'), andOAuthRoutes::registerIfConfigured('{id}')inroutes/oauth.php. - Document env vars on
docs/drivers/{id}/configuration.md.
Custom flows
Use built-in routes when the default global owner and shipped scopes are enough. Use your own routes/controllers when you need different owners, scopes, or callbacks — still call$driver->oauth()->getAuthorizationUrl() / exchangeCode() with a matching OAuthProviderConfig.
Drivers today
See Authentication.
