TokenBroker

Home / Token Setup / Zoho

Token Setup: Zoho

Zoho Mail through TokenBroker. Completed 2026-11-28; accounts and search verified end to end the same day.

Zoho facts that shape the setup

The client

A dedicated Self Client in the Zoho API Console (https://api-console.zoho.com), created for TokenBroker alone. Do not reuse the server-based client that belongs to the Muse Zoho connector; that client and its secret stay untouched.

Scopes (exactly these six):

ZohoMail.accounts.READ,ZohoMail.messages.READ,ZohoMail.messages.CREATE,ZohoMail.messages.DELETE,ZohoMail.messages.UPDATE,ZohoMail.folders.READ

Vault secrets

In kv-tokenbroker-example, names exactly:

Secret What it is
zoho-client-id Self Client id
zoho-client-secret Self Client secret (typed into the portal by the owner, never in chat)
zoho-refresh-token Written by the exchange script during bootstrap

Configuration (in appsettings.json, not app settings): Providers:Zoho:AccountsBase = https://accounts.zoho.com, Providers:Zoho:MailBase = https://mail.zoho.com, plus KeyVaultUri in the gitignored appsettings.Local.json pointing at the vault.

Bootstrap steps (the one-time ceremony)

Part A and B are done once. Part C is repeated only if the refresh token is ever lost or revoked.

Part A: the Self Client. In the API Console, open (or create) the TokenBroker Self Client and note its Client ID and Client Secret.

Part B: id and secret into the vault. Azure portal, vault kv-tokenbroker-example, Objects, Secrets, Generate/Import, manual: create zoho-client-id and zoho-client-secret with the values from Part A.

Part C: the grant code. In the Self Client, Generate Code tab: paste the six-scope line above, choose the longest duration (10 minutes), description "TokenBroker bootstrap", Create. The code is single-use and expires in minutes: pass it to the exchange step immediately.

Exchange. Run an exchange script (a small shell script kept with the operator's tooling, not in this repo) with the grant code. The script reads the id and secret from the vault (printing only their lengths), posts grant_type=authorization_code to https://accounts.zoho.com/oauth/v2/token, and on success stores the refresh token as zoho-refresh-token. It prints no token values.

Endpoints the function exposes

All require the x-functions-key header.

Route Proxies to
GET /api/zoho/mail/accounts Zoho mail accounts list
GET /api/zoho/mail/search?accountId=..&q=..&limit=.. Zoho message search
GET /api/zoho/mail/read?accountId=..&folderId=..&messageId=.. One message
POST /api/zoho/mail/send (JSON: accountId, fromAddress, toAddress, subject, content) Zoho send

Routes were originally /api/mail/*; they were namespaced per provider in the 2026-11-28 refactor, before any caller depended on them.

Verification (2026-11-28)

Troubleshooting