Home / Token Setup
Token Setup
How TokenBroker holds tokens, and the pattern every provider follows. Provider-specific steps live on their own subpages; Zoho is the first (see the link at the bottom).
The pattern
- A dedicated OAuth client per provider, owned by TokenBroker. Never reuse a client that belongs to another tool. TokenBroker gets its own client id and secret so revoking or rotating one tool never breaks the other.
- Secrets live only in Azure Key Vault (kv-tokenbroker-example). The client secret is typed straight into the vault by the account owner. It is never pasted into chat, never stored on the assistant's machine, and never committed to this repo.
- The refresh token is minted once, by hand. OAuth grant codes are single-use and live only a few minutes, so the bootstrap is a short, attended ceremony: the owner generates a code, the assistant exchanges it immediately, and the refresh token goes directly into the vault. See the Zoho page for the worked example.
- The function mints access tokens at call time. The provider's token service (the shared OAuthTokenService base) reads the client id, client secret, and refresh token from the vault through the Function App's managed identity (DefaultAzureCredential), exchanges the refresh token at the provider, caches the access token in memory, and refreshes five minutes before expiry. Providers rate-limit refresh: Zoho allows at most 10 access tokens per refresh token per 10 minutes, which is why the cache matters.
- Callers authenticate with the Azure function key (header
x-functions-key). The key is the only credential a caller holds; it unlocks the proxy, not the provider.
Security rules
- Vault access is RBAC: the Function App's managed identity has Key Vault Secrets User (read only). The account owner has Key Vault Secrets Officer for the bootstrap and rotations.
- No secret value is ever printed by a script or a runbook step. Scripts report lengths and HTTP status codes only.
- Grant codes are single-use. If an exchange fails after the code is consumed, generate a fresh code; the client id and secret stay in the vault and do not need to be redone.
- Rotating a provider secret means: update the vault secret, restart the Function App (to drop the in-memory cache), re-test one call.
Adding a new provider (checklist)
- Register a dedicated OAuth client for TokenBroker with the provider; note the exact scopes the proxy needs, no more.
- Put
<provider>-client-idand<provider>-client-secretin the vault (owner types them in the Azure portal). - Add a token service and proxy functions under
src/TokenBroker, following the Zoho shape; add the provider's base URLs as app settings (<Provider>AccountsBase,<Provider>MailBasestyle). - Build clean, deploy (see Azure Foundation), and confirm the new functions are listed.
- Run the grant-code bootstrap; store
<provider>-refresh-tokenin the vault. - Test one read call end to end with the function key; record the date and result on the provider's wiki page.
- Add the provider page under this section: scopes, secret names, endpoints, limits, and its troubleshooting notes.
Doing it yourself
- Setup Guide and its Adding a Provider walkthrough turn this pattern into followable steps.
Providers
- Zoho: Zoho Mail, live since 2026-11-28.
- Azure Foundation: the shared Azure side every provider stands on.