# Intuit QuickBooks Online API tokens: find, store, rotate, and use them safely with AI agents

Source: https://botpassword.com/keys/intuit-quickbooks
Last checked: 2026-11-08

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.

## Key types

| Type | Prefix | Secret | Scope | Expiry |
|---|---|---|---|---|
| Client ID and client secret | — | 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 | — | Yes | Obtains new access tokens | 100 days, rolling, extended on each use; five-year maximum |

## How to create a Intuit QuickBooks Online key

1. Sign in to your Intuit Developer account and open your app.
2. For sandbox testing, go to the **Development** section and select **Keys & OAuth**; for a live app use the **Production** section.
3. Copy the client ID and client secret, and register your HTTPS redirect URI.
4. Send the user to the authorization URL with the scopes you need, such as `com.intuit.quickbooks.accounting`, and a `state` value.
5. Exchange the returned authorization code for access and refresh tokens, and store both.

## 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

1. Exchange the current refresh token at the token endpoint for a new access token.
2. Store the new `access_token` and `refresh_token` values from the response, replacing the old ones.
3. Refresh one request at a time; a second parallel refresh with the same token returns `invalid_grant`.

## How to revoke a Intuit QuickBooks Online key

1. POST the refresh token or access token as `token` to `https://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.
2. A successful revocation returns HTTP 200; a 400 response includes an error message to follow.

## If the key leaked

1. Revoke the exposed refresh or access token at the revoke endpoint.
2. Ask the affected QuickBooks users to reconnect your app, which issues fresh tokens.
3. Review the QuickBooks company data the app could reach for changes you did not make.

## Gotchas

- 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.

## Using this key with AI agents (BotPassword)

- `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.

## FAQ

### 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.

## Sources

- https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization/faq
- https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization/oauth-2.0
- https://developer.intuit.com/app/developer/qbo/docs/get-started/get-client-id-and-client-secret
