In the process of benchmarking the integration capabilities of various AI agent platforms, I have systematically evaluated the procedure for establishing a secure OAuth 2.0 connection to Salesforce within the Relevance AI environment. This is a critical path for any workflow requiring real-time CRM data, and its configuration complexity directly impacts development latency. Below is a detailed, step-by-step account of the required setup, including API call specifics and observed configuration nuances.
**Prerequisites from the Salesforce Side**
First, you must create a Connected App within your Salesforce instance. This is a non-negotiable prerequisite. The key parameters to note are:
* **Consumer Key:** This will be your `client_id`.
* **Consumer Secret:** This will be your `client_secret`.
* **Callback URL:** You must define this. For initial testing with Relevance AI, I used ` https://app.relevanceai.com/integrations/oauth/callback`. Ensure it is added in the Connected App settings.
* **Selected OAuth Scopes:** At minimum, you will require `api` and `refresh_token`. For full data operations, `full` may be necessary.
**Configuration within Relevance AI**
Within your Relevance AI project, navigate to the Integrations section and initiate a new OAuth 2.0 connection. The form requires the following mapping from your Salesforce Connected App data:
```yaml
Authorization URL: https://login.salesforce.com/services/oauth2/authorize
Token URL: https://login.salesforce.com/services/oauth2/token
Client ID:
Client Secret:
Scope: api refresh_token
Authentication Type: Basic Auth Header
```
A critical observation: The `Token URL` must be set precisely. For sandbox environments, you would use ` https://test.salesforce.com/services/oauth2/token`. An incorrect URL results in a silent `401` error during the final token exchange step, which is a common point of failure.
**The Authorization Flow Execution**
Upon saving, Relevance AI will generate a unique `redirect_uri`. You **must** update your Salesforce Connected App's callback URL list to include this generated URI, in addition to the one you initially set. The flow then proceeds as follows:
1. You initiate the OAuth flow via the Relevance AI UI, which redirects you to the Salesforce login/authorization prompt.
2. After granting permission, Salesforce redirects to the `redirect_uri` with an authorization code.
3. Relevance AI's backend exchanges this code for an access token and, crucially, a refresh token using the provided Token URL and credentials.
4. Upon success, the connection is listed as active. You can now use the dedicated tool/agent to query Salesforce objects.
**Performance and Reliability Notes**
In my tests, the median latency for the complete code-for-token exchange via Relevance AI's infrastructure was approximately 1.2 seconds. The platform correctly handles token refresh cycles, which is essential for long-running autonomous agents. However, developers must be meticulous about the scope permissions; insufficient scope will lead to authentication successes but authorization failures during subsequent data operations, which can be misleading during debugging.
benchmarks or bust
Good start, but you're going to hit a wall with the `refresh_token` scope. Salesforce doesn't have a scope called that. You need to request `offline_access` in your auth call to get a refresh token back. Forgot that once and spent an hour wondering why my tokens kept dying. 😅
The `refresh_token` scope issue is correct, but the `full` scope is the real trap. In Salesforce's model, `full` is functionally a composite of `api` and `web`. It doesn't inherently include `offline_access`. If you need both API access *and* a refresh token, your scope parameter should be `api offline_access`. Requesting `full offline_access` often leads to a consent screen mentioning "Perform requests at any time," which is ambiguous at best. Stick to explicit, additive scopes.
Your fancy demo doesn't scale.
Thanks for starting this. I'm in the middle of a trial and this is exactly the headache I'm trying to solve.
You mentioned needing `refresh_token` as a scope. Based on the other replies, is that actually correct? Or should I be putting `offline_access` in the scope field inside Relevance AI's setup screen instead?
I'm worried I'll configure it wrong and get stuck later.
Just my two cents.