MetorialDocs

Connect Salesforce to your AI agents with per-user OAuth

Publish Salesforce in a Metorial portal so each employee signs in to production, a sandbox or My Domain, with your own External Client App and read-only tools.

To connect Salesforce, an admin shares the Salesforce integration in a portal and each employee signs in with their own Salesforce user. The agent then queries and changes records with that user's profile, permission sets and sharing rules, so it never sees a record the person cannot see. The integration works with production orgs, sandboxes and My Domain login hosts.

What you'll learn

  • How an admin publishes Salesforce and how an employee connects
  • How to point the integration at a sandbox or your My Domain
  • How to use your own External Client App and block write tools

Before you start

Sign-in method

Salesforce has one method, OAuth 2.0. It uses the authorization code flow with PKCE and a refresh token. There is no username and password method and no API token method.

Choose the Salesforce environment

The integration has an environment setting that decides where people sign in.

environmentSign-in host
production (default)login.salesforce.com
sandboxtest.salesforce.com
customThe host in customDomain, for example <my-domain>.my.salesforce.com

Use custom when your org blocks sign-in through the shared login hosts. customDomain accepts the short name, the full host or a URL. A second setting, apiVersion, sets the Salesforce REST API version and defaults to v62.0.

To offer production and a sandbox side by side, share two Salesforce integrations with different environments and name them clearly.

Admin: publish Salesforce in a portal

In the dashboard

Open Shared Resources

Open Workforce, choose the portal, and select Shared Resources under Access.

Share a new integration

Select Share a Resource, then New Integration, and choose Salesforce. Set the environment. For how members connect, choose Each person connects.

To have every agent act as one Salesforce integration user, choose Shared connection and connect it once with that user.

Choose who gets it

Add the access groups that should see Salesforce.

With the CLI

The CLI cannot create the per-user integration. Once it exists, list who has it:

metorial-admin portals access list <portal-id> --type provider_template --search salesforce

Employee: connect your Salesforce user

In the portal

Open Salesforce in the catalog

Sign in to your portal and open Salesforce.

Authenticate

Under Quick setup, select Authenticate. A Salesforce tab opens. Sign in and allow access.

Confirm

The status changes to Configured. If it later reads Needs reconnect, select Reconnect.

With the CLI

metorial catalog search salesforce
metorial setup <catalog-item-id>

Scopes

ScopeWhat it allowsRequested by default
apiREST API access to dataYes
refresh_tokenStay connected without signing in againYes
openid, profileIdentify the signed-in userYes
chatter_apiChatter feeds and postsNo
wave_apiAnalyticsNo
cdp_apiData CloudNo
pardot_apiAccount EngagementNo
custom_permissionsRead the user's custom permissionsNo
fullEverything the user can doNo

Salesforce scopes do not separate reading from writing. api covers both. To limit what the agent can change, use the Salesforce user's permissions and Metorial's tool permissions, described below.

Use your own External Client App

Start the credentials in Metorial

In the dashboard, select Settings, then Organization Settings. Under Integrations and MCP, select Provider Auth, then Create Auth Credentials. Choose Salesforce and copy the Redirect URI.

Create the app in Salesforce

In Salesforce Setup, enter App Manager in Quick Find and open it. Select New External Client App. Enter a name, an API name and a contact email, and keep the distribution state Local.

Turn on OAuth

In the app's OAuth Settings, select Enable OAuth. Paste the redirect URI from Metorial into Callback URL. Select the OAuth scopes you plan to request, including the one for refresh tokens. Select Require Secret for the Web Server Flow, Require Secret for Refresh Token Flow and Require Proof Key for Code Exchange (PKCE) extension for Supported Authorization Flows. Save.

Finish in Metorial

Copy the app's consumer key and consumer secret from its OAuth settings. In Metorial, enter a Name, the consumer key as Client ID and the consumer secret as Client Secret, select the same scopes, and select Create.

Salesforce's steps are in Create a local external client app and Configure the OAuth settings.

An app created in one org is known only to that org. If you connect production and a sandbox, check that the app exists in both, or create one in each and store two sets of credentials.

Make the connection read-only

Open the integration's Tool Filters and set the write and destructive tool groups to Reject. Read tools such as query_records, get_record, search_records and describe_object stay available. Tools such as create_record, update_record and delete_record are no longer offered to any agent. See Tool permissions.

For a stronger guarantee, also connect with a Salesforce user whose profile is read-only on the objects that matter.

Check it worked

metorial list salesforce
metorial tools <integration-id>
metorial call <integration-id> get_org_limits
metorial call <integration-id> query_records -d '{"soql": "SELECT Id, Name FROM Account LIMIT 5"}'

get_org_limits takes no input and proves the token works. The query proves the user can read data.

Next steps