Overview
This document provides a step-by-step guide on how to obtain an OAuth token from Salesforce. The process involves acquiring the Client ID and Client Secret, configuring Salesforce for API access, and making an API call with the required credentials.
Prerequisites
Administrator access to Salesforce.
A Salesforce Developer or Production environment.
API access enabled for your Salesforce instance.
A valid username and password for an Administrator account.
Security Token.
Step 1: Create a Connected App in Salesforce
To obtain the Client ID and Client Secret, you need to create a Connected App in Salesforce.
Log into Salesforce with an administrator account.
Navigate to Setup (Click on the gear icon in the upper-right corner and select Setup).
In the Quick Find box, search for App Manager.
Click on App Manager.
Click External Client App Manager in the top right corner.
Fill out the basic details:
Connected App Name: (e.g., SharpenCX)
API Name: Auto-filled
Contact Email: Enter your email
Under API (Enable OAuth Settings), check Enable OAuth Settings.
Set the Callback URL (e.g.,
https://[your-instance].my.salesforce.com/).Under Available OAuth Scopes, select the appropriate access level:
When connecting external applications to Salesforce, ensure both your Connected App settings and integration user permissions comply with your organization's security requirements. Balance minimum necessary access with your integration needs, and consult your security team when in doubt.
Example:
Create a dedicated integration user with minimal permissions required for the connection to function.
Configure the Connected App with specific OAuth scopes instead of
Full access (full)to limit data exposure.
This layered security approach (defense-in-depth) provides better protection for your Salesforce data. Consult with your Salesforce administrator or security team to ensure compliance with your organization's security policies.
Click Save and then Continue.
On the next screen, under API (Enable OAuth Settings), note the Consumer Key (Client ID) and Consumer Secret (Client Secret). Store them securely.
Step 2: Retrieve Your Salesforce Security Token
Salesforce requires a Security Token in addition to the password for authentication.
Log into Salesforce.
Click on your Profile Picture (top-right corner) and select Settings.
In the Quick Find box, search for Reset My Security Token.
Click Reset Security Token.
Salesforce will email the new Security Token to your registered email address.
Store the Security Token securely.
For future use, you will need to append your Salesforce Security Token to your login password. The format should be:
password = yourSalesforceLoginPassword + yourSalesforceSecurityToken
Step 3: Make the API Call to Retrieve the OAuth Token
Use Logic+ to perform this API call.
Integration (Base URL):
https://[your-instance].my.salesforce.comPath:
/services/oauth2/tokenRequest Method:
POSTRequest Headers:
{
"Content-Type": "application/x-www-form-urlencoded"
}Request Body:
{
"grant_type": "client_credentials",
"client_id": "$(clientId)",
"client_secret": "$(clientSecret)",
"username": "$(username)",
"password": "$(password)"
}Content Type:
Form DataVariables:
Define a variable to store your token, using the JSONPath syntax as demonstrated below.
$.data.access_tokenStep 4: Handling the Response
Upon successful authentication, the API will return a JSON response with the access token, typically accompanied by a 200 status code. Here's a representative example:
{
"status": 200,
"data": {
"access_token": "[your_token_here]",
"signature": "Z4h6PtaFoC+KfJmGFGFKLJGVfdgdfgaHS6HjrMD8=",
"instance_url": "https://[your-instance].my.salesforce.com",
"id": "https://login.salesforce.com/id/00Dak00000DFDFDEA5/004ik00000BsniBDDR",
"token_type": "Bearer",
"issued_at": "1737750891800"
},
"statusText": "OK",
"headers": {
"date": "Fri, 24 Jan 2025 20:34:51 GMT",
"content-type": "application/json;charset=UTF-8",
"transfer-encoding": "chunked",
"connection": "close",
"set-cookie": "CookieConsentPolicy=0:1; path=/; expires=Sat, 24-Jan-2026 20:34:51 GMT; Max-Age=31536000; secure, LSKey-c$CookieConsentPolicy=0:1; path=/; expires=Sat, 24-Jan-2026 20:34:51 GMT; Max-Age=31536000; secure, BrowserId=qZS0p9qSEe-DqP3RzYFYDQ; domain=.salesforce.com; path=/; expires=Sat, 24-Jan-2026 20:34:51 GMT; Max-Age=31536000; secure; SameSite=None",
"vary": "Accept-Encoding",
"strict-transport-security": "max-age=63072000; includeSubDomains",
"x-content-type-options": "nosniff",
"expires": "Thu, 01 Jan 1970 00:00:00 GMT",
"x-robots-tag": "none",
"cache-control": "no-cache,must-revalidate,max-age=0,no-store,private",
"server": "sfdcedge",
"x-sfdc-request-id": "1234567890",
"x-request-id": "123456789"
}
}Store the access_token securely, as it will be required for subsequent API requests.
Conclusion
Following this guide, you have successfully:
Created a Connected App to obtain Client ID and Client Secret.
Retrieved the Security Token for authentication.
Made an OAuth token request using username, password, client ID, and client secret.
Warning – If your Salesforce password expires in accordance with your organization's Salesforce password policy, you must update both your Salesforce login password and security token in the password to restore API functionality (e.g., Salesforce record lookups).
password = yourSalesforceLoginPassword + yourSalesforceSecurityToken
For additional details, refer to Salesforce OAuth Documentation.