SAP Cloud Platform Open Connectors

QuickBooks Online Authenticate A connector

You can authenticate with QuickBooks to create your own instance of the QuickBooks Online connector through the UI or through APIs. Once authenticated, you can use the connector instance to access the different functionality offered by the QuickBooks platform.

Authenticate Through the UI

Use the UI to authenticate with QuickBooks and create a connector instance. Because you authenticate with QuickBooks via OAuth 2.0, all you need to do is add a name for the instance. After you create the instance, you'll log in to QuickBooks to authorize SAP Cloud Platform Open Connectors access to your account. For more information about authenticating a connector instance, see Authenticate A connector Instance (UI)

After successfully authenticating, we give you several options for next steps. Make requests using the API docs associated with the instance, map the instance to a virtual data resource, or use it in a formula template.

Authenticate Through API

Authenticating through API is a multi-step process that involves:

Getting an OAuth Token

Use the following API call to request an Oauth Token. Replace 'keyOrId' with the connector key, quickbooks. You will also need to replace 'apikey', 'apisecret' and 'callbackUrl'.

GET /elements/{keyOrId}/oauth/token?apiKey=<api_key>&apiSecret=<api_secret>&callbackUrl=<url>
Query Parameters
Query ParameterDescription
apiKeyThe key obtained from registering your app with the provider. This is the Consumer Key that you recorded in the API Provider Setup section.
apiSecretThe secret obtained from registering your app with the provider. This is the Consumer Secret that you recorded in the API Provider Setup section.
callbackUrlThe URL that will receive the code from the vendor to be used to create a connector instance. This is the Callback URL that you noted at the end of the API Provider Setup section.
Example cURL
curl -X GET
-H 'Content-Type: application/json'
https://api.openconnectors.us2.ext.hana.ondemand.com/elements/api-v2/elements/{keyOrId}/oauth/token?apiKey=<api_key>&apiSecret=<api_secret>&callbackUrl=<url>'
Example Response
{
  "secret": "xxxxxx",
  "token": "xxxxxxx"
}

You will use the token returned on this call to get the redirect URL and to provison the instance. The secret returned will be used as the oauth.api.user.secret.

Getting a Redirect URL

Use the following API call to request a redirect URL where the user can authenticate with the API provider. Replace {keyOrId} with the connector key, quickbooks.

GET /elements/{keyOrId}/oauth/url?apiKey=<api_key>&apiSecret=<api_secret>&callbackUrl=<url>&requestToken=insert_fake_request_token&state=quickbooks
Query Parameters
Query ParameterDescription
apiKeyThe key obtained from registering your app with the provider. This is the Consumer Key that you recorded in the API Provider Setup section.
apiSecretThe secret obtained from registering your app with the provider. This is the Consumer Secret that you recorded in the API Provider Setup section.
callbackUrlThe URL that will receive the code from the vendor to be used to create a connector instance. This is the Callback URL that you noted at the end of the API Provider Setup section.
requestTokenThe token returned from the previous step.
Example cURL
curl -X GET
-H 'Content-Type: application/json'
'https://api.openconnectors.us2.ext.hana.ondemand.com/elements/api-v2/elements/quickbooks/oauth/url?apiKey=fake_api_key&apiSecret=fake_api_secret&callbackUrl=https://www.mycoolapp.com/auth&state=quickbooks'
Example Response

Use the oauthUrl in the response to allow users to authenticate with the vendor.

{
"element": "quickbooks",
"oauthUrl": "https://appcenter.intuit.com/Connect/Begin?oauth_token=<fake_token>&oauth_callback=<fake_callback>%3Fstate%3Dquickbooks"
}

Authenticating Users and Receiving the Authorization Grant Code

Provide the response from the previous step to the users. After they authenticate, QuickBooks Online provides the following information in the response:

  • oauth_verifier
  • realmId
Response ParameterDescription
oauth_verifierThe Authorization Grant Code required by SAP Cloud Platform Open Connectors to retrieve the OAuth access and refresh tokens from the endpoint.
realmIDThe unique identifier for the authorized QuickBooks Online company.
dataSourceThis value determines what data source should be used for the connection.
Note: If the user denies authentication and/or authorization, there will be a query string parameter called error instead of the code parameter. In this case, your application can handle the error gracefully.

Authenticating the Connector Instance

Use the /instances endpoint to authenticate with QuickBooks and create a connector instance. If you are configuring events, see the Events section.

Note: The endpoint returns a connector token upon successful completion. Retain the token for all subsequent requests involving this connector instance.

To create a connector instance:

  1. Construct a JSON body as shown below (see Parameters):

    {
      "element": {
        "key": "quickbooks"
      },
      "providerData": {
        "oauth_token": "<OAUTH_TOKEN>",
        "realmId": "<REALMID>",
        "oauth_verifier": "<OAUTH_VERIFIER>",
        "secret": "<OAUTH_USER_SECRET>",
        "state": "quickbooks",
        "dataSource": "<dataSource>"
      },
      "configuration": {
        "oauth.callback.url": "<CALLBACK_URL>",
        "oauth.api.key": "<CONSUMER_KEY>",
        "oauth.api.secret": "<CONSUMER_SECRET>",
        "filter.response.nulls": true
      },
      "tags": [
        "<Add_Your_Tag>"
      ],
      "name": "<INSTANCE_NAME>"
    }
    
  2. Call the following, including the JSON body you constructed in the previous step:

    POST /instances
    
    Note: Make sure that you include the User and Organization keys in the header. For more information, see Authorization Headers, Organization Secret, and User Secret.
  3. Locate the token and id in the response and save them for all future requests using the connector instance.

Example cURL
curl -X POST \
  https://api.openconnectors.us2.ext.hana.ondemand.com/elements/api-v2/instances \
  -H 'authorization: User <USER_SECRET>, Organization <ORGANIZATION_SECRET>' \
  -H 'content-type: application/json' \
  -d '{
  "element": {
    "key": "quickbooks"
  },
  "providerData": {
    "oauth_token": "<OAUTH_TOKEN>",
    "realmId": "<REALMID>",
    "oauth_verifier": "<OAUTH_VERIFIER>",
    "secret": "<OAUTH_USER_SECRET>",
    "state": "quickbooks",
    "dataSource": "QBO"
  },
  "configuration": {
    "oauth.callback.url": "<CALLBACK_URL>",
    "oauth.api.key": "<CONSUMER_KEY>",
    "oauth.api.secret": "<CONSUMER_SECRET>"
  },
  "tags": [
    "For Docs",
    "tag 2"
  ],
  "name": "QBO_Instance"
}'
Parameters

API parameters not shown in SAP Cloud Platform Open Connectors are in code formatting.

Note: Event related parameters are described in Events.
ParameterDescriptionData Type
'key'The connector key.
quickbooks
string
Name
name
The name for the connector instance created during authentication.Body
oauth_verifierA verification code generated by Intuit that an App is supposed to pass back during the getaccesstoken step.
oauth_tokenThe token retrieved in the Getting an Oauth Token step.
secretA secret to establish the ownership of the token.
realmIdAn identifier unique to QuickBooks that identifies the company that the authenticated instance is connected to.
stateThis should always be quickbooks
dataSourceThis value determines what data source should be used for the connection. It is returned after authentication.
oauth.callback.urlThe Callback URL from QuickBooks. This is the Callback URL that you noted at the end of the API Provider Setup section..
oauth.api.keyThe Consumer Key from QuickBooks. This is the Consumer Key that you noted at the end of the API Provider Setup section.string
oauth.api.secretThe Consumer Secret from QuickBooks. This is the Consumer Secret that you noted at the end of the API Provider Setup section.string
Filter null values from the response
filter.response.nulls
Optional. Determines if null values in the response JSON should be filtered from the response. Yes or true indicates that SAP Cloud Platform Open Connectors will filter null values.
Default: true.
boolean
tagsOptional. User-defined tags to further identify the instance.string
Example Response
{
    "id": 123,
    "name": "test",
    "token": "3sU/S/kZD36BaABPS7EAuSGHF+1wsthT+mvoukiE",
    "element": {
        "id": 39,
        "name": "QuickBooks Online",
        "key": "quickbooks",
        "description": "Add a QuickBooks Online Instance to connect your existing QuickBooks Online account to the Finance Hub, allowing you to manage your customers, employees, invoices, purchase orders etc. across multiple Finance connectors. You will need your QuickBooks Online account information to add an instance.",
        "active": true,
        "deleted": false,
        "typeOauth": true,
        "trialAccount": false,
        "configDescription": "If you do not have an QuickBooks account, you can create one at <a href=\"http://quickbooks.intuit.com/signup/\" target=\"_blank\">QuickBooks Signup</a>",
        "signupURL": "http://quickbooks.intuit.com/signup/"
    },
    "provisionInteractions": [],
    "valid": true,
    "eventsEnabled": true,
    "disabled": false,
    "maxCacheSize": 0,
    "cacheTimeToLive": 0,
    "cachingEnabled": false
}

Token Based Authentication

The QuickBooks Online connector also allows for token based authentication. To provision an instance using this method, you are still required to have all of the OAuth information ahead of time.

Example cURL

curl -X POST \
  https://api.openconnectors.us2.ext.hana.ondemand.com/elements/api-v2/instances \
  -H 'authorization: User <USER_SECRET>, Organization <ORGANIZATION_SECRET>' \
  -H 'content-type: application/json' \
  -d '{
  "element": {
    "key": "quickbooks"
  },
  "configuration": {
    "oauth.callback.url":"<INSERT_CALLBACK_URL>",
    "quickbooks.datasource": "<INSERT_DATASOURCE>",
    "oauth.user.refresh_interval": "<INSERT_REFRESH_INTERVAL>",
    "quickbooks.realm.id" : "<INSERT_REALM_ID>",
    "oauth.user.token":"<INSERT_USER_TOKEN>",
    "oauth.user.token.secret":"<INSERT_USER_TOKEN_SECRET>",
    "oauth.api.key": "<INSERT_API_KEY>",
    "oauth.api.secret": "<INSERT_API_SECRET>"
  },
  "tags": [
    "QBO Token"
  ],
  "name": "QBO Token",
  "externalAuthentication": "initial"
}'

Parameters for Token Based Authentication

API parameters not shown in SAP Cloud Platform Open Connectors are in code formatting.

Note: Event related parameters are described in Events.
ParameterDescriptionData Type
'key'The connector key.
quickbooks
string
Name
name
The name for the connector instance created during authentication.Body
"oauth.user.refresh_interval"In seconds, the amount of time that should pass before a refresh needs to take place. The default for QuickBooks Online is 151 days or 13046400.
oauth.user.tokenThe token retrieve in the Getting an Oauth Token step.
oauth.user.token.secretA secret to establish the ownership of the token.
quickbooks.realm.idThe unique Identifier for the authorized QuickBooks company.
stateThis should always be quickbooks
quickbooks.dataSourceThis value determines what data source should be used for the connection.
oauth.callback.urlThe Callback URL from QuickBooks. This is the Callback URL that you noted at the end of the API Provider Setup section.
oauth.api.keyThe Consumer Key from QuickBooks. This is the Consumer Key that you noted at the end of the API Provider Setup section.string
oauth.api.secretThe Consumer Secret from QuickBooks. This is the Consumer Secret that you noted at the end of the API Provider Setup section.string
Filter null values from the response
filter.response.nulls
Optional. Determines if null values in the response JSON should be filtered from the response. Yes or true indicates that SAP Cloud Platform Open Connectors will filter null values.
Default: true.
boolean
tagsOptional. User-defined tags to further identify the instance.string

Example Response

{
    "id": 123,
    "name": "test",
    "token": "3sU/S/kZD36BaABPS7EAuSGHF+1wsthT+mvoukiE",
    "element": {
        "id": 39,
        "name": "QuickBooks Online",
        "key": "quickbooks",
        "description": "Add a QuickBooks Online Instance to connect your existing QuickBooks Online account to the Finance Hub, allowing you to manage your customers, employees, invoices, purchase orders etc. across multiple Finance connectors. You will need your QuickBooks Online account information to add an instance.",
        "active": true,
        "deleted": false,
        "typeOauth": true,
        "trialAccount": false,
        "configDescription": "If you do not have an QuickBooks account, you can create one at <a href=\"http://quickbooks.intuit.com/signup/\" target=\"_blank\">QuickBooks Signup</a>",
        "signupURL": "http://quickbooks.intuit.com/signup/"
    },
    "provisionInteractions": [],
    "valid": true,
    "eventsEnabled": true,
    "disabled": false,
    "maxCacheSize": 0,
    "cacheTimeToLive": 0,
    "cachingEnabled": false
}