QuickBooks Online API access uses OAuth 2.0: an app's client ID and client secret come from Keys & OAuth in the Intuit Developer portal, and the authorization flow returns an access token that lasts one hour and a refresh token that lasts 100 days on a rolling basis. Intuit changes the QuickBooks refresh token value every 24 hours, so always store the newest one.
Intuit QuickBooks Online key types
| Type | Prefix | Secret? | Scope | Expiry |
|---|---|---|---|---|
| Client ID and client secret The client secret is the sensitive half. Production keys appear only after Intuit approves the production key questionnaire. | — | Yes | Identify and authenticate your app; development and production keys are separate | — |
| Access token | — | Yes | The scopes the user authorized, such as `com.intuit.quickbooks.accounting`, for one QuickBooks company | 1 hour (3,600 seconds) |
| Refresh token Intuit updates the value every 24 hours; when a new refresh token is issued the previous value expires. | — | Yes | Obtains new access tokens | 100 days, rolling, extended on each use; five-year maximum |
How to create a Intuit QuickBooks Online key
- Sign in to your Intuit Developer account and open your app.
- For sandbox testing, go to the Development section and select Keys & OAuth; for a live app use the Production section.
- Copy the client ID and client secret, and register your HTTPS redirect URI.
- Send the user to the authorization URL with the scopes you need, such as
com.intuit.quickbooks.accounting, and astatevalue. - Exchange the returned authorization code for access and refresh tokens, and store both.
Open Intuit QuickBooks Online's key settings
Limiting what the key can do
The scope list in the authorization request decides which QuickBooks data and APIs the app can reach, for example com.intuit.quickbooks.accounting for accounting data and openid for sign-in. Intuit recommends requesting scopes incrementally; changing scopes means running the authorization flow again and the user re-authorizing.
How to rotate a Intuit QuickBooks Online key
- Exchange the current refresh token at the token endpoint for a new access token.
- Store the new
access_tokenandrefresh_tokenvalues from the response, replacing the old ones. - Refresh one request at a time; a second parallel refresh with the same token returns
invalid_grant.
The refresh token is rolling for 100 days and has a five-year hard limit, after which the user must authorize again. Using a stale refresh token value returns invalid_grant.
How to revoke a Intuit QuickBooks Online key
- POST the refresh token or access token as
tokentohttps://developer.api.intuit.com/v2/oauth2/tokens/revoke, with Basic auth made from the client ID and client secret. This revokes the tokens and removes the app's permissions. - A successful revocation returns HTTP 200; a 400 response includes an error message to follow.
If your Intuit QuickBooks Online key leaked
- Revoke the exposed refresh or access token at the revoke endpoint.
- Ask the affected QuickBooks users to reconnect your app, which issues fresh tokens.
- Review the QuickBooks company data the app could reach for changes you did not make.
Things that catch people out
- Access tokens last one hour; a 401 usually means the token expired.
- The refresh token value changes every 24 hours even though the token is valid for 100 days, so write the new value atomically after every refresh.
- Development and production use separate keys, and production keys appear only after the production key questionnaire is approved.
- Redirect URIs must use HTTPS and cannot be IP addresses.
Common Intuit QuickBooks Online authentication errors
invalid_grant
The redirect URI does not match, the authorization code was reused, the wrong development or production keys were used, or the refresh token is expired, stale or revoked.
401 unauthorized
The access token has expired (it lasts 60 minutes), or the user disconnected the app.
Using your Intuit QuickBooks Online key with AI agents
A coding agent that can read your .env file or your shell history can read the key, and anything in its context can end up in logs, transcripts or a prompt-injected request. The safer pattern is to keep the key in a credential broker that performs the authenticated step for the agent and hands back only the result.
BotPassword works this way. For a Intuit QuickBooks Online key, these intents fit:
| Intent | What BotPassword does |
|---|---|
run_with | Runs a command with the key injected as an environment variable or a 0600 temporary file, never on the command line, and redacts the key from the output. |
http_request | Makes an authenticated API call after checking the destination against the hosts this key may be sent to. The response comes back with credential-shaped values redacted, and one that holds the key itself is refused. |
rotate | Partly built: creates a new key, stores it as pending, verifies it, promotes it, then revokes the old key after a grace period. Today it works for Cloudflare tokens and AWS IAM keys you have set up, and an agent can start it only under a grant with autopilot; other providers cannot be rotated through their API yet. |
store_secret | Saves a value the agent already holds as a new vault item. |
Set it up in your agent: Aider · Amp · Claude Code · Claude Desktop · Cline · OpenAI Codex CLI · all agents
Frequently asked questions
How long do QuickBooks API tokens last?
QuickBooks access tokens last 1 hour; refresh tokens last 100 days on a rolling basis, up to a five-year maximum.
Where do I find my QuickBooks client ID and secret?
In the Intuit Developer portal, open your app and select Keys & OAuth under Development (sandbox) or Production (live).
Why does the QuickBooks refresh token change?
Intuit updates the refresh token value every 24 hours as a security measure. The previous value expires, so always store the one from the most recent response.
How do I fix invalid_grant from QuickBooks?
Check the redirect URI and keys match the environment, never reuse an authorization code, and refresh with the newest refresh token one request at a time.
How do I revoke a QuickBooks OAuth token?
POST the token to https://developer.api.intuit.com/v2/oauth2/tokens/revoke with Basic auth from your client ID and secret.
Can an AI agent use my Intuit QuickBooks Online key without seeing it?
Yes, if the key never enters the agent's context. Instead of pasting the key into a chat or leaving it in a .env file the agent can read, keep it in a credential broker that injects it into the command or request on the agent's behalf. BotPassword does this with run_with, http_request, store_secret, so the agent gets the result and never the value.