Authenticate to Xero with OAuth 2.0, handle multi-tenant token storage, and refresh access tokens

domain: developer.xero.com · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Register an application in Xero Developer Portal and obtain client_id and client_secret; set the redirect URI for the authorization code flow
  2. Redirect the user to https://login.xero.com/identity/connect/authorize with scopes including 'openid profile email accounting.transactions offline_access'
  3. Exchange the authorization code at https://identity.xero.com/connect/token for an access token and refresh token; store both securely per-tenant
  4. Call GET https://api.xero.com/connections to retrieve the list of Xero organisations (tenants) the user has connected; each has a 'tenantId'
  5. Include the 'Xero-Tenant-Id' header on every API call set to the target tenantId; omitting it causes a 403
  6. Use the refresh token to obtain a new access token before expiry; handle 400 errors on token refresh by prompting the user to reconnect

Known gotchas

Related routes

Create an invoice in Xero with OAuth 2.0 multi-tenant handling
developer.xero.com · 6 steps · unrated
Authenticate to the Brivo Access API with OAuth 2.0 and manage users and credentials
apidocs.brivo.com · 5 steps · unrated
Authenticate with the project44 API using OAuth 2.0 client credentials and manage token refresh for continuous shipment visibility calls
project44.com · 5 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans