How to Connect to Salesforce REST API with OAuth 2.0

Document created by Adam Arrowsmith Employee on Apr 19, 2016Last modified by Adam Arrowsmith Employee on Jul 24, 2017
Version 3Show Document
  • View in full screen mode

The following describes the AtomSphere and Salesforce configuration to setup a connection to the Salesforce REST API with OAuth 2.0 authentication.


IMPORTANT: This approach uses the HTTP Client connector, not the Salesforce connector. In Salesforce OAuth 2.0 terms, it follows the web server flow.


  1. In Salesforce create a new Connected App in Salesforce. This "Connected App" will represent AtomSphere as a whole. Below is the relevant configuration:
    • Consumer Key
    • Consumer Secret (guard this as a password)
    • Selected OAuth Scopes:
      • Full access (full) - or customize based on the level of desired access
      • Perform requests on your behalf at any time (refresh_token, offline_access) - IMPORTANT Always add this to allow the integration to automatically refresh the access token without user intervention
    • Callback URL =<ATOMSPHERE-ACCOUNT-ID>/oauth2/callback
    • To navigate back to the OAuth setup screen:
      • In Salesforce Classic UI, go to Setup | App Setup | Create | Apps | scroll down to Connected Apps | click the Connected App Name (do not click Edit or Manage).
      • In Salesforce Lightning UI, go to Setup | Apps | App Manager | choose "View" from the drop down menu to the right (do not choose Edit or Manage).
  2. In AtomSphere create a new HTTP Connection. Below is the relevant configuration:
  3. Generate the access token:
    • Click Generate... next to Access Token. You will need to do this once. The token will be automatically refreshed upon expiration.
    • AtomSphere dialog drops down and a new browser tab opens with the Salesforce authorization dialog.
    • In the authorization dialog click Allow. Browser tab redirects with simple message "Authorization Code received". Close that browser tab.
    • Back in the connection, dialog updates to "Access Token generation successful". Dismiss dialog.
    • Access Token is now populated. Save and close connection component.
  4. Create a new HTTP Operation. Below is the relevant configuration:
    • HTTP Method = GET (for queries) or POST (for creates, updates, upserts, deletes)
    • Resource Path = Configure static and/or dynamic resource path elements to construct the appropriate URL for the desired action. Examples:
      • Query: query/?q=SELECT+name+from+Account+LIMIT+2
      • Create: sobjects/Account/
  5. Execute the process. Additional considerations:
    • Results are returned in a single JSON document.
    • Use an example response to generate a JSON profile for mapping.
    • When querying the HTTP connector will not automatically iterate through pages of results. The process must be designed to recursively invoke the query with a nextRecordsUrl value if present. See Design Pattern: Handling API Pagination.


General Reference

11 people found this helpful