Authentication
OAuth for interactive MCP clients and API keys for scripts, CI, and custom agents.
SheetBase has two MCP authentication paths. Both resolve to the same SheetBase user, then use that user’s connected Google account when a Sheets or Drive tool runs. Google is the only sign-in method for the SheetBase dashboard.
The canonical MCP endpoint is:
https://sheetbase.flonest.app/api/mcpAuth paths at a glance
| OAuth 2.1 + OIDC JWT | API Key (x-api-key) | |
|---|---|---|
| Best for | Claude, Cursor, ChatGPT, and interactive MCP clients | Scripts, CI pipelines, and custom agents |
| How it works | Browser sign-in and consent → resource-bound JWT | Generate a key from the dashboard → pass it as a header |
| Stored in | Better Auth user/session plus OAuth Provider tables | Better Auth apikey table |
| Revocation | Remove the client or reconnect it | Revoke the individual key in the dashboard |
| Rate limiting | Database-backed limits on auth endpoints | Per-key database-backed limits |
Do not send both an OAuth bearer token and an API key in the same request. SheetBase rejects mixed credentials.
Path 1 — OAuth for interactive MCP clients
SheetBase uses Better Auth’s stable oauthProvider() and jwt() plugins. The OAuth Provider handles client registration, PKCE authorization, consent, refresh tokens, and standards-based discovery. JWT access tokens are verified locally against the exact SheetBase issuer and MCP resource.
OAuth identity
| Item | Canonical value |
|---|---|
| Issuer | https://sheetbase.flonest.app |
| MCP resource | https://sheetbase.flonest.app/api/mcp |
| JWKS | https://sheetbase.flonest.app/api/auth/jwks |
A token must be issued by SheetBase, include the MCP resource as an audience, and include all required scopes. Invalid signatures, expired tokens, future-dated tokens, wrong issuers, wrong audiences, opaque tokens, and incomplete scopes are rejected.
Discovery endpoints
MCP clients discover the flow automatically from these routes:
GET /.well-known/openid-configuration
GET /.well-known/oauth-authorization-server
GET /.well-known/oauth-protected-resource/api/mcpThe discovered authorization endpoints live under /api/auth/oauth2/*, including client registration, authorization, token exchange, refresh, revocation, and user information.
Flow
MCP client
│
├─ Discovers the SheetBase authorization server and MCP resource
├─ Registers a guarded redirect URI
├─ Opens the browser for sign-in
├─ Requests consent using PKCE
├─ Receives a resource-bound JWT and refresh token
└─ Calls the MCP endpoint with Authorization: Bearer <token>The consent page shows the requesting client and the signed-in SheetBase account. Redirect addresses must use HTTPS, except for standard loopback HTTP addresses used by installed local clients.
One-time reconnect after the OAuth security migration
The stable OAuth Provider uses fresh client and token records. Existing OAuth clients and tokens from the retired provider are intentionally invalidated, so interactive MCP clients must reconnect once.
User accounts remain, Google account connections remain, sessions remain, and API keys remain. Follow Reconnect SheetBase OAuth for the client-side steps.
Path 2 — API Key (x-api-key)
Generate an API key from your dashboard at https://sheetbase.flonest.app/dashboard. The key is shown once—copy it immediately and store it securely.
curl https://sheetbase.flonest.app/api/mcp \
-H "x-api-key: YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "MCP-Protocol-Version: 2025-06-18" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'For MCP clients that support custom headers:
{
"mcpServers": {
"sheetbase": {
"url": "https://sheetbase.flonest.app/api/mcp",
"headers": {
"x-api-key": "YOUR_KEY_HERE"
}
}
}
}API keys resolve to the same SheetBase user context as OAuth. Existing API keys are not invalidated by the OAuth Provider migration.
Name keys clearly, such as CI pipeline or Cursor headless, so one key can be revoked without affecting other clients. Never paste a key into a URL, issue, log, or chat message.
Google OAuth scopes
The Google account connection is separate from the MCP client authorization flow.
| Scope | Purpose |
|---|---|
openid, email, profile | Basic Google identity |
https://www.googleapis.com/auth/spreadsheets | Sheets read/write |
https://www.googleapis.com/auth/drive.readonly | List spreadsheets in Drive |
https://www.googleapis.com/auth/drive.file | Create and convert files |
SheetBase requests
drive.readonlyfor listing anddrive.filefor files it creates or opens—not unrestricted full-Drive access.
Token and connection lifecycle
| Event | Behaviour |
|---|---|
| First OAuth connection | Browser sign-in, consent, PKCE exchange, resource-bound JWT |
| Normal reconnect | Stored consent may be reused; refresh happens automatically |
| OAuth security migration | Remove and add the MCP connection once; old OAuth clients and tokens no longer work |
| Access token expires | The MCP client uses its refresh token to obtain a fresh access token |
| OAuth client or token is revoked | The client must connect again |
| Google refresh token is revoked | Sheet tools return an authentication-required error; reconnect the Google account from the dashboard |
| API key is revoked | That key stops working immediately; other keys and OAuth clients are unaffected |
User-facing routes
| Route | Purpose |
|---|---|
/login | Sign in with Google |
/authorize | Review and allow or deny an MCP client request |
/dashboard | Manage API keys, Google connection status, and sign-out |