How to register Salesforce App and obtain Client ID / Secret (for API Call / OAuth)

Introduction

In this section, we will discuss how to register OAuth App to call Salesforce API using Client ID / Secret rather than using your User Id / Password. Once you follow these steps below to register your Salesforce App (OAuth App), at the end you will get a Client ID (sometimes referred to as App Id) and Client Secret (or App Secret). These two pieces can be used later on to call Salesforce API using OAuth. So let's get started.

Register Salesforce App

  1. Login into your account and go to Setup as shown below (click on gear icon at the top right corner): Accessing Salesforce Setup to create an OAuth App
  2. Then in the search bar input "app" and open App Manager: Searching Salesforce App Manager to create an OAuth App
  3. Then click New Connected App to create a new OAuth App: Creating a Salesforce App to get data via ODBC driver
  4. Give your App a name and: - Enable OAuth Settings - Set callback URL to following two URLs (one in each line) https://login.salesforce.com/services/oauth2/success https://zappysys.com/oauth - Add an OAuth scope you want or simply add "Full access". - Add "Perform requests on your behalf at any time (offline_token)" scope to get a refresh token so that you don't have to re-authenticate each time requesting an access token: Configuring Salesforce App OAuth settings to get data via ODBC driver
  5. Click "Save".

Get Client Id and Client Secret for Salesforce App

Once App is created we need to find out App Id / Secret so we can use it for API calls.
  1. Go to App Manager
  2. Find out recently created App and click View (click on the small arrow to the right)
  3. Once App page is loaded you can Copy Consumer Key and Consumer Secret (click on reveal to see). Also copy anyone Call back URL (We will need this for OAuth Connection > Advanced Tab > Call Back URL or Redirect URL property depending on which ZappySys Product / Driver you are using)
  4. That's it, you can now use these 3 pieces to ZappySys OAuth connection UI or on Salesforce Connection UI (new version with OAuth support). The above screenshot is showing where to enter these 3 pieces on New Salesforce Connection. For OAuth Connection redirect URL goes to Advanced Tab > Callback URL textbox.

(OPTIONAL) Configure Salesforce OAuth refresh token validity

By default, Salesforce Refresh Token doesn't expire once you generate. If you like to change default behavior you can follow these steps.
  1. Go to "Manage Connected Apps" menu item and press on your App name: Finding Salesforce App to configure its policies
  2. Click "Edit Policies" to configure refresh token validity: Editing Salesforce App OAuth refresh token issuing policy
  3. Set "All users may self-authorize" and "Refresh token is valid until revoked" options: Making Salesforce App OAuth refresh token to never expire
  4. Click "Save".

Using Salesforce Connection with OAuth App in SSIS / ODBC

Once you have Client ID / Secret you can use in the Salesforce Connection in SSIS Connector / ODBC Driver for salesforce like below (Only new version will have OAuth option)

Troubleshooting Known Issues

Let’s look at some common issues with Salesforce Connection and how to fix them.

OAuth Error: Missing Required Code Challange

When you click Generate Token button, you may get an error like the one below.

Salesforce OAuth Generate Token Error - Missing Required Code Challenge

Salesforce OAuth Generate Token Error – Missing Required Code Challenge

Solution

Here is how to fix it.

For Salesforce Connection UI: Go to Advanced Tab => Check Enable PKCE Code Verifier option
–OR–
For OAuth Connection UI: Go to OAuth2 Grant Options Tab => Check Enable Code Verifier Option

Enable PKCE code verifier  option - OAuth Connection for Salesforce

Enable PKCE code verifier option – OAuth Connection for Salesforce.

Posted in Salesforce Driver, SSIS Salesforce Connection, SSIS Salesforce Destination, SSIS Salesforce Source and tagged , , , .