Token VaultDocs
Reference

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.

Loading diagram...

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"
200 OK
{
  "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"]
    }
  ]
}
FieldTypeNotes
supportedbooleanWhether your webhook advertises the oauth-callback capability
redirectUristring or nullRegister this as the redirect URI in your provider app. null before a webhook is bound
webhookConfigKeystringThe webhook secret that holds your client secret
providers[].providerstringgoogle, github, spotify, or the key of a custom provider you defined
providers[].custombooleantrue for a provider you defined
providers[].clientIdstring or nullWhat you saved
providers[].scopesstring[]The effective scopes: yours, or the defaults
providers[].customScopesbooleantrue if you overrode the defaults
providers[].authorizeUrl, providers[].tokenUrlstringCustom 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 fieldTypeRequiredNotes
clientIdstringyes4 to 256 characters of A-Za-z0-9._~:@+-, starting with a letter or digit
scopesstring[]noUp to 30, each 1 to 200 of A-Za-z0-9._:/-+. Empty or omitted means the defaults
authorizeUrl, tokenUrlstringcustom onlyhttps 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"}'
200 OK
{ "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"}'
HTTPCodeWhen
400RESERVED_PROVIDERThe key is custom, pending, list, tv, tokenvault or oauth
400BUILTIN_PROVIDER_URLSURLs were sent for google, github or spotify
400INVALID_PROVIDERThe key is not 2 to 32 lower-case letters, digits, - or _, starting with a letter
400INVALID_URLA 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
400TOO_MANY_PROVIDERSYou 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 fieldTypeRequiredNotes
servicestringyesThe 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"}'
200 OK
{
  "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

HTTPCodeWhen
400INVALID_SERVICEBad credential name
400(bare detail)OAuth connect needs a webhook vault. Or a reserved name
400CLIENT_ID_MISSINGSave the client id first
404UNKNOWN_PROVIDERNot google, github, spotify or a custom provider you saved
409WEBHOOK_UNSUPPORTEDThe webhook lacks oauth-callback. Update it
412(bare detail)Webhook not configured.
423VAULT_LOCKEDYou stopped all access
429TOO_MANY_PENDING20 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.

200 OK
{ "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:

410 Gone
{
  "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.

On this page