Overview
This document describes the authentication flow and REST API endpoints used by the Cloud Maven QuickBooks Connector to integrate a Salesforce org with Intuit QuickBooks Online.
1. Authentication
The connector uses OAuth 2.0 Authorization Code Flow via a Cloud Maven middleware site. No tokens are ever held or persisted by the middleware — it acts purely as a redirect relay.
1.1 Authentication Flow (Step-by-Step)
Client Salesforce Org → Cloud Maven Middleware → QuickBooks (Intuit)
|
Step |
Actor |
Action |
|---|---|---|
|
1 |
User |
Opens the Connect to QuickBooks button in the Salesforce app, which loads |
|
2 |
|
Builds the authorization URL pointing to the Cloud Maven middleware site and redirects the browser |
|
3 |
Middleware ( |
Constructs the Intuit OAuth URL and redirects the user to the QuickBooks login page |
|
4 |
User |
Logs in to QuickBooks and grants access |
|
5 |
Intuit |
Redirects back to the Cloud Maven middleware with |
|
6 |
Middleware |
Relays |
|
7 |
|
Exchanges the auth code for |
|
8 |
|
Calls the Company Info endpoint to retrieve company details |
|
9 |
Salesforce |
Stores tokens and company info in |
1.2 Authorization URL Construction
The initial redirect URL built by QBAuthController follows this pattern:
https://cloudmaveninc.my.salesforce-sites.com/sms/QB_AuthVFPage
?stateURL={State_URL from Quickbooks_Credentials__c}
&clientId={Client_ID or Sandbox_Client_ID}
-
Middleware Base URL:
https://cloudmaveninc.my.salesforce-sites.com -
Middleware Path:
/sms -
Page:
QB_AuthVFPage
The
clientIdsent depends on the configured API instance:
Production →
Client_ID__cSandbox →
Sandbox_Client_ID__c
1.3 Token Exchange (Authorization Code → Access Token)
After the middleware relays the auth code back to the client org, QBAuthController calls WS_Quickbooks.getAccessToken(), which makes the following POST request:
|
Property |
Value |
|---|---|
|
Method |
|
|
URL |
|
|
Authorization Header |
|
|
Content-Type |
|
|
Accept |
|
Request Body:
grant_type=authorization_code
&code={authCode}
&redirect_uri=https://cloudmaveninc.my.salesforce-sites.com/sms/QB_AuthVFPage
Success Response (HTTP 200):
{
"access_token": "...",
"refresh_token": "...",
"token_type": "bearer",
"expires_in": 3600,
"x_refresh_token_expires_in": 8726400
}
Both tokens are stored on the company's Quickbooks_Credentials__c record. The Refresh_Token_Last_Modified_Date__c is stamped with the current datetime.
1.4 Token Refresh
When the access token expires, WS_Quickbooks.refreshAccessToken() is called automatically. It uses the same token endpoint with a different grant type:
|
Property |
Value |
|---|---|
|
Method |
|
|
URL |
|
|
Authorization Header |
|
|
Content-Type |
|
Request Body:
grant_type=refresh_token
&refresh_token={storedRefreshToken}
1.5 Callback / Redirect Handling
Once the browser is redirected back to the client's QBAuthVFPage with parameters, the controller validates inputs and handles both success and error cases:
|
Parameter |
Description |
|---|---|
|
|
|
|
|
OAuth 2.0 authorization code (alphanumeric + dashes, max 256 chars) |
|
|
QuickBooks Company ID (alphanumeric + dashes, max 256 chars) |
|
|
Set by Intuit if the user denied access or an error occurred |
On success, the VF page displays a confirmation message and auto-closes after 2.5 seconds. On failure, an error is displayed and a QB_Auth__e platform event is fired with Is_Success__c = false.
2. Base URLs
|
Environment |
Base URL |
|---|---|
|
Production |
|
|
Sandbox |
|
|
OAuth Token Endpoint |
|
|
Middleware (Cloud Maven) |
|
The active instance (Production vs Sandbox) is controlled by the
ApiInstancesetting inQuickbooks_Common_Settings__c. Default: Production.
All QuickBooks API calls use Minor Version 75 (minorversion=75).
3. API Endpoints
All endpoints below are relative to the applicable Base URL. Path parameters use {0}, {1}, {2} notation as stored in the Quickbooks_Credentials__c custom setting.
|
Operation |
Method |
Endpoint Pattern |
Path Parameters |
|---|---|---|---|
|
Get Company Info |
GET |
|
|
|
Query (SOQL-style) |
GET |
|
|
|
Create Account |
POST |
|
|
|
Create Customer |
POST |
|
|
|
Create Vendor |
POST |
|
|
|
Create Invoice |
POST |
|
|
|
Create Sales Receipt |
POST |
|
|
|
Get Invoice PDF |
GET |
|
|
|
Get Sales Receipt PDF |
GET |
|
|
|
Create Product (Item) |
POST |
|
|
|
Update Product (Item) |
POST |
|
|
|
Create Journal Entry |
POST |
|
|
|
Create Payment |
POST |
|
|
|
Create Payment Method |
POST |
|
|
|
Get Payment Receipt PDF |
GET |
|
|
|
Batch Operations |
POST |
|
|
|
Preferences |
GET |
|
|
4. Request Headers (All API Calls)
|
Header |
Value |
|---|---|
|
|
|
|
|
|
|
|
|
5. Common Settings Reference
These values are seeded on package install via PostInstallScript into the Quickbooks_Common_Settings__c custom setting and can be changed post-install.
|
Setting Name |
Default Value |
Description |
|---|---|---|
|
|
|
Toggles between |
|
|
|
Cloud Maven middleware base URL |
|
|
|
Path segment appended to middleware URL |
|
|
(set post-auth) |
QuickBooks realmId of the default company |
|
|
|
Max records per batch sync operation |
|
|
|
Auto-generate PDF on invoice creation |
|
|
|
Auto-generate PDF on sales receipt creation |
|
|
|
Auto-send payment receipts |
|
|
|
Support contact for error notifications |
6. Security Notes
-
All
authCodeandrealmIdvalues received via callback are sanitized: HTML-escaped, Java-escaped, single-quote-escaped, and XML-escaped before use. -
Only alphanumeric characters, dashes (
-), and underscores (_) are accepted forauthCodeandrealmId. Any other characters result in an immediate auth failure. -
Client credentials (
clientId,clientSecret) are stored in the encryptedQuickbooks_Credentials__cprotected custom setting and are never logged or exposed in the UI. -
The middleware never stores tokens — it relays only the authorization code and realmId back to the client org.