OAuth Apps API
Reference for the endpoints behind Connect with your own OAuth app, where the provider redirects to your webhook and Token Vault never sees the code, the token or the client secret.
Connect a Google, GitHub or Spotify credential through an OAuth app you registered. Token Vault holds your client id (not a secret) and signs a one-shot state ticket. The provider redirects to your webhook, which exchanges the code with its own client secret and stores the token. How it works for people: OAuth apps.
All endpoints are human only (a signed-in web session). Keys and agents get 403 HUMAN_ONLY.
The client secret goes on the webhook, in its OAUTH_PROVIDERS_JSON secret. Never send it to Token Vault. Webhook side of the flow: OAuth callback.
GET /api/oauth-apps
What you saved per provider, and what to register. Read-only.
curl -s https://api.tokenvault.uk/api/oauth-apps -H "Authorization: Bearer $FIREBASE_ID_TOKEN"{
"supported": true,
"redirectUri": "https://hook.example.com/v1/oauth/callback",
"webhookConfigKey": "OAUTH_PROVIDERS_JSON",
"providers": [
{
"provider": "github",
"label": "GitHub",
"clientId": "Iv1.8a61f9b3a7aba766",
"scopes": ["repo", "read:user"],
"customScopes": false,
"defaultScopes": ["repo", "read:user"]
},
{
"provider": "google",
"label": "Google",
"clientId": null,
"scopes": ["openid", "email", "profile"],
"customScopes": false,
"defaultScopes": ["openid", "email", "profile"]
}
]
}| Field | Type | Notes |
|---|---|---|
supported | boolean | Whether your webhook advertises the oauth-callback capability |
redirectUri | string or null | Register this as the redirect URI in your provider app. null before a webhook is bound |
webhookConfigKey | string | The webhook secret that holds your client secret |
providers[].provider | string | google, github, spotify, or the key of a custom provider you defined |
providers[].custom | boolean | true for a provider you defined |
providers[].clientId | string or null | What you saved |
providers[].scopes | string[] | The effective scopes: yours, or the defaults |
providers[].customScopes | boolean | true if you overrode the defaults |
providers[].authorizeUrl, providers[].tokenUrl | string | Custom providers only |
Default scopes: Google openid email profile (identity only, so ask for API scopes such as Gmail or Drive explicitly), GitHub repo read:user, Spotify user-read-email. A custom provider has no defaults.
PUT /api/oauth-apps/{provider}
Save the client id, and optionally override the scopes. Needs the kill switch off.
| Body field | Type | Required | Notes |
|---|---|---|---|
clientId | string | yes | 4 to 256 characters of A-Za-z0-9._~:@+-, starting with a letter or digit |
scopes | string[] | no | Up to 30, each 1 to 200 of A-Za-z0-9._:/-+. Empty or omitted means the defaults |
authorizeUrl, tokenUrl | string | custom only | https URLs for a custom provider. Refused for a built-in |
curl -s -X PUT https://api.tokenvault.uk/api/oauth-apps/github \
-H "Authorization: Bearer $FIREBASE_ID_TOKEN" -H "Content-Type: application/json" \
-d '{"clientId":"Iv1.8a61f9b3a7aba766"}'{ "provider": "github", "clientId": "Iv1.8a61f9b3a7aba766", "scopes": ["repo", "read:user"] }Changing the client id, scopes or URLs decides which app tokens are minted with, so it needs a sign-in within 5 minutes (401 REAUTH_REQUIRED). Saving the same values again does not.
Custom providers
Any {provider} that is not built in is a custom provider, and the body must carry authorizeUrl and tokenUrl. Everything is non-secret account metadata. Token Vault checks the URLs for shape only and never calls them, and the authorize URL is not in the state ticket (the webhook builds it from its own config).
curl -s -X PUT https://api.tokenvault.uk/api/oauth-apps/acme \
-H "Authorization: Bearer $FIREBASE_ID_TOKEN" -H "Content-Type: application/json" \
-d '{"clientId":"acme-client-1","scopes":["read","write"],"authorizeUrl":"https://auth.acme.example/authorize","tokenUrl":"https://auth.acme.example/token"}'| HTTP | Code | When |
|---|---|---|
| 400 | RESERVED_PROVIDER | The key is custom, pending, list, tv, tokenvault or oauth |
| 400 | BUILTIN_PROVIDER_URLS | URLs were sent for google, github or spotify |
| 400 | INVALID_PROVIDER | The key is not 2 to 32 lower-case letters, digits, - or _, starting with a letter |
| 400 | INVALID_URL | A URL is missing, not https, has credentials or a fragment, uses a port below 1024 other than 443, or names localhost, a single-label host, a .local/.internal host or a private or reserved IP address |
| 400 | TOO_MANY_PROVIDERS | You already defined 10. Remove one |
The webhook needs a matching entry (with the same key, its own tokenUrl and authorizeUrl, and the client secret) in OAUTH_PROVIDERS_JSON. See OAuth apps.
DELETE /api/oauth-apps/{provider}
Forget the client id, or, for a custom provider, the provider. No re-sign-in. Returns {"deleted": true}; 404 UNKNOWN_PROVIDER for a custom key that does not exist.
POST /api/oauth-apps/{provider}/connect
Start a connect. Token Vault makes no outbound call: it signs a state ticket, records a pending connect, and returns the webhook URL the browser should open.
| Body field | Type | Required | Notes |
|---|---|---|---|
service | string | yes | The credential name to store the token under. Letters, digits, . _ - and spaces. Reserved names are refused |
curl -s -X POST https://api.tokenvault.uk/api/oauth-apps/github/connect \
-H "Authorization: Bearer $FIREBASE_ID_TOKEN" -H "Content-Type: application/json" \
-d '{"service":"github"}'{
"startUrl": "https://hook.example.com/v1/oauth/start?state=eyJwdXIiOiJvYXV0aF9jb25uZWN0Ii...",
"expiresIn": 600
}Open startUrl in the browser. The state is signed with your webhook's HMAC secret, lives 10 minutes and works once. The PKCE verifier is derived by the webhook from a key of its own and the ticket nonce, so it never travels through the browser and Token Vault cannot compute it.
The call also runs the same bookkeeping as a store ticket (existence check, creation claim) and marks the credential as refreshed by the webhook, so Token Vault never takes the TV-mediated refresh path for it.
Errors
| HTTP | Code | When |
|---|---|---|
| 400 | INVALID_SERVICE | Bad credential name |
| 400 | (bare detail) | OAuth connect needs a webhook vault. Or a reserved name |
| 400 | CLIENT_ID_MISSING | Save the client id first |
| 404 | UNKNOWN_PROVIDER | Not google, github, spotify or a custom provider you saved |
| 409 | WEBHOOK_UNSUPPORTED | The webhook lacks oauth-callback. Update it |
| 412 | (bare detail) | Webhook not configured. |
| 423 | VAULT_LOCKED | You stopped all access |
| 429 | TOO_MANY_PENDING | 20 connects in flight. Wait a few minutes |
For a custom provider the state ticket carries prv (the key), tku (the saved token URL), clid and scp, like a built-in.
GET /api/oauth-apps/pending/list
Connects started and not yet expired, so the result page can say which credential you were connecting. Metadata only.
{ "pending": [{ "service": "github", "provider": "github", "createdAt": 1793611200 }] }createdAt is Unix seconds. Newest first.
Result redirect
After the provider consent, the webhook redirects the browser to <frontend>/tokens/oauth-result?status=...&service=...&provider=... (kept for webhooks already deployed). The web app forwards it to /credentials/oauth-return, which resumes the Add flow.
Refresh
A token stored this way is refreshed by your webhook, using the non-secret oauth hint it stored with the token. See Token refresh.
Removed: Token Vault's own OAuth app
POST /api/oauth/google/exchange, /github/exchange and /spotify/exchange used to swap a code for tokens with Token Vault's client secret. That put tokens in Token Vault, so they are turned off:
{
"detail": {
"code": "OAUTH_CONNECT_DISABLED",
"message": "Connecting through Token Vault's own OAuth app is turned off, because it put your tokens in Token Vault. Paste the token in the web app instead (type JWT with its refresh token)."
}
}Ready to try it?
Sign in with Google or email. Your credentials stay on your own webhook, and the quickstart gets Claude Code making its first MCP tool call in about 15 minutes.
MCP Servers API
Reference for the endpoints that attach MCP servers to a credential, refresh their cached tool lists, and list the built-in presets.
tvault CLI
Complete command reference for the tvault CLI, covering install, contexts and login, every command with its flags and aliases, output conventions and exit codes.