This guide explains how to retrieve the Client ID, Client Secret, Authorization Code, Access Token, Refresh Token, and Instance URL for OAuth 2.0 integration with Salesforce.
We’ll use Postman and curl to demonstrate the flow.
Step 1: Get Client ID
and Client Secret
from Salesforce Dashboard
-
Log into Salesforce with an admin account.
-
In the top-right, click the gear icon → Setup.
-
In the left sidebar, search for App Manager and click it.
-
Click New Connected App (or find an existing one and click View).
-
Fill in:
-
Scroll down to API (Enable OAuth Settings) and:
-
Click Save. You may need to wait a few minutes for the app to become active.
-
Go back to App Manager, find your app, and click View.
You’ll now see:
Step 2: Generate Authorization Code (using Postman)
-
Open Postman
-
Create a new OAuth 2.0 authorization under the Authorization tab
-
Fill in:
-
Click Get New Access Token
-
You will be redirected to Salesforce → login and allow access.
-
Postman will receive a redirect like:
Copy the value of code=...
– this is your Authorization Code.
Step 3: Exchange Authorization Code for Tokens
Use the following curl
command to exchange the authorization code for:
-
access_token
-
refresh_token
-
instance_url
CURL example:
curl -X POST https://login.salesforce.com/services/oauth2/token \
-d "grant_type=authorization_code" \
-d "client_id=YOUR_CLIENT_ID" \
-d "client_secret=YOUR_CLIENT_SECRET" \
-d "redirect_uri=https://oauth.pstmn.io/v1/callback" \
-d "code=YOUR_AUTHORIZATION_CODE"
Example Response:
{
"access_token": "00Dxx000000S1on!...",
"refresh_token": "5Aep86...etc",
"instance_url": "https://na123.salesforce.com",
"id": "https://login.salesforce.com/id/...",
"issued_at": "1711734351000",
"signature": "abcdef123456="
}