The Call External API action can be used to set up Salesforce authentication within the Mavenoid assistant builder. This allows you to retrieve an access token and interact with Salesforce's REST APIs. While Salesforce offers various authentication methods, it's recommended to use the OAuth 2.0 Refresh Token Flow for Renewed Sessions.
Follow these steps to configure Salesforce authentication in the Mavenoid assistant builder:
Create a Salesforce Integration User
Ensure you have created a Salesforce Integration User (API-only user) with the necessary permissions. For more information, refer to the Creating a Salesforce Integration User (API-only User) guide.
Configure a Connected App for OAuth 2.0
Create a Connected App in Salesforce for the OAuth 2.0 Client Credentials Flow. Enable the following OAuth settings:
OAuth Scopes:
Manage user data via APIs (API)
Perform requests at any time (refresh_token, offline_access)
Callback URL: https://app.mavenoid.com/integrations/salesforce/oauth
Enable Client Credentials Flow
Update OAuth Policies
Update the OAuth policies as shown in the image.
Retrieve Consumer Key and Secret
Retrieve the Consumer Key and Consumer Secret for the connected app.
Get an Authorization Code:
Go to the URL: https://YOUR_SALESFORCE_DOMAIN.my.salesforce.com/services/oauth2/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_CALLBACK_URL&response_type=code
Login using your Integration User.
If the login is successful, the authorization code will be at the end of the URL ?code={authorization_code}
Get a Refresh Token:
Make a POST request to Saleforce API /services/oauth2/token
with the following URL-encoded parameters in the body of the request:
grant_type: authorization_code
redirect_uri: YOUR_CALLBACK_URL
client_id: YOUR_CONSUMER_KEY
client_secret: YOUR_CONSUMER_SECRET
code: YOUR_AUTHORIZATION_CODE
Add a Secret in Mavenoid
In Mavenoid, add a secret with the value of client_id:client_secret
base64 encoded. For detailed instructions, refer to the article Understand secrets in Mavenoid.
Configure the Call External API action
We're now ready to configure the Call External API action in the assistant builder to get the Salesforce Access Token. Make a POST request to services/oauth2/token
with the following URL-encoded parameters in the body of the request:
grant_type: refresh_token
refresh_token: YOUR_REFRESH_TOKEN
Handle API Response
Connect the Call External API action node to a Read Data node to verify if the API call successfully retrieved an access token or returned an error.
If an error occurs, guide the user to an alternative (such as contacting an agent).
Use the Access Token
Reference the access token retrieved in Step 8 for any subsequent Call External API actions when interacting with Salesforce REST APIs.