How it works
- You register an OAuth app with the service and get a
client_idandclient_secret - Corsair generates an authorization URL for the user to visit
- After the user approves, the service redirects back with an authorization code
- Corsair exchanges the code for access and refresh tokens and stores them encrypted
- On every API call, Corsair checks token expiry and refreshes automatically
corsair.ts
Solo setup
Solo mode connects a single account to your application. Use this for scripts, internal tools, or apps that only ever connect one account.corsair.ts
usage.ts
Multi-tenant setup
In multi-tenant mode, each user connects their own account. You need an OAuth callback route in your application that Corsair processes.corsair.ts
1. Store your OAuth app credentials
Store your client credentials once — these are shared across all tenants:2. Generate the authorization URL
When a user wants to connect their account, redirect them to the authorization URL:app/api/connect/gmail/route.ts
3. Handle the callback
After the user approves, the service redirects to your callback URL. Process it with Corsair:app/api/oauth/callback/route.ts
tenantId from the state parameter, exchanges the code for tokens, and stores them encrypted for that tenant.
4. Make API calls per tenant
usage.ts