Xero
Complete Xero onboarding from your client backend.
Preview · What this means for your integration
Your backend completes Xero authorization, selects an organization and sends its tokens and tenant ID. Zwapgrid checks access and takes over token refresh.
First, complete the shared prerequisites and example setup.
What you need
Your own Xero OAuth web application. See the Xero setup guide.
A Published Xero System Setting containing that application's client ID and secret, belonging to your Zwapgrid client.
The same client ID and secret available securely to your backend for code exchange.
Your backend callback URL registered on the Xero application. Use this URL for headless authorization; keep the guided callback if you also use guided onboarding.
OAuth scopes
Zwapgrid needs these scopes to access your customer's accounting data:
openid profile email accounting.contacts accounting.settings accounting.attachments accounting.invoices accounting.reports.profitandloss.read offline_access1. Prepare the connection
Use the Consent created in the shared workflow. Make sure
systemsSettings.xerocontains your published setting ID.Start Xero's authorization-code flow at
https://login.xero.com/identity/connect/authorizewithresponse_type=code, your application'sclient_id, registered backend callback, the OAuth scopes above, and random, expiring session/Consent-boundstate.Validate callback state and exchange the code in your backend at
https://identity.xero.com/connect/token. Send a form-encoded POST withgrant_type=authorization_code, the code and exactredirect_uri, authenticating with HTTP Basic using your application's client ID and secret.Call
GET https://api.xero.com/connectionswith the resulting bearer access token. Choose an accessible entry withtenantType: ORGANISATION. You can select the sole organization automatically, or ask the customer to choose when several are available. Use itstenantId, not the Xero connectionid.If your backend is refreshing these tokens, stop it and wait for any refresh in progress to finish. Send the latest tokens and selected tenant ID once. Keep your refresh process stopped until you confirm the result.
See Xero's authorization-code flow for provider authorization and token requests.
2. Send the request
All three fields are required. Access tokens are limited to 8192 characters and refresh tokens to 4096 characters. tenantId must be a non-empty UUID. Do not send the authorization code, redirect URI, PKCE verifier or application secret.
Send both tokens for the selected organization. Zwapgrid verifies access before completing the connection. Your customer does not need to authorize again or choose an organization in Zwapgrid.
Replace the placeholders and save this body as a protected connection.json on your backend. Set the example variables, including a new UUID in CORRELATION_ID, then send the request once:
3. Check the result
Expect HTTP 201 with source: xero and state: completed. Optionally verify the connection.
After confirmed success, Zwapgrid owns refresh. Let Zwapgrid manage refresh for this authorization. Do not keep refreshing it in your backend or submit its tokens for another connection. If POST is uncertain, keep refresh paused and recover with GET. A missing result does not prove the submitted refresh token is usable. Authorize again if you cannot confirm whether the tokens are still valid; do not resubmit old tokens.
Last updated
Was this helpful?
