How it works
- You register an OAuth app with the service and get a
client_idandclient_secret - Your app calls
client.connect.createLink()and redirects the user to the returned URL - 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
client.connect.createLink() and redirect the user to the returned URL. See Connect / OAuth for the full reference.
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. Configure Hub and mount the management handler.corsair.ts
app/api/corsair/[[...path]]/route.ts
1. Store your OAuth app credentials
Store your client credentials once. These are shared across all tenants:2. Create a connect link
When a user wants to connect, mint a link from your authenticated backend and redirect them:app/actions/connect.ts
connect-button.tsx
state is embedded in connectUrl. Hub hosts the connect page and OAuth callback, so you do not build those routes yourself.
3. Make API calls per tenant
usage.ts