Get credentials for server-to-server authentication

Server-to-server authentication uses the OAuth 2.0 client credentials flow to allow applications to access Salesforce data without interactive user sign-in. Instead of signing in through a browser, the application uses a Consumer Key (Client ID) and Consumer Secret (Client Secret) to obtain an access token from Salesforce.

The access token is issued on behalf of a specified Salesforce user, whose permissions determine which data the application can access.

This authentication method is suitable for background services, integrations, and automated processes that require non-interactive access to Salesforce data.

Create an external client app

To create an external client app for server-to-server authentication:

1. Sign in to Salesforce and navigate to Setup.

2. Go to Apps > External Client Apps > External Client App Manager.

3. Click New External Client App.

Creating a new external client app.

4. In the Basic Information section, enter the required application details. Under Distribution State, select Local.

Configuring basic information for an external client app.

5. In the API (Enable OAuth Settings) section, select Enable OAuth.

6. In the Callback URL field, enter a URL, such as http://localhost:56420, or another supported localhost URL.

7. Under OAuth Scopes, add Manage user data via APIs to Selected OAuth Scopes.

Configuring OAuth scopes for an external client app.

8. In the Flow Enablement section, select Enable Client Credentials Flow.

9. In the Security section, clear all checkboxes.

Enabling the client credentials flow and configuring security settings.

10. Click Create.

Obtain the consumer key and consumer secret

After creating the external client app, retrieve its OAuth credentials.

1. In Salesforce Setup, go to Apps > External Client Apps > External Client App Manager.

2. Locate and open your external client app.

Opening an external client app to retrieve OAuth credentials.

3. Go to Settings > OAuth Settings > Consumer Key and Secret.

Opening the Consumer Key and Secret settings.

4. On the Verify Your Identity page, enter the verification code sent to your email address, then click Verify.

Verifying your identity in Salesforce.

5. Copy and securely store the Consumer Key (Client ID) and Consumer Secret (Client Secret).

Retrieving the Consumer Key and Consumer Secret.

Configure OAuth policies

To enable the client credentials flow and specify the user on whose behalf Salesforce access tokens will be issued:

1. Open the Policies tab of your external client app and click Edit.

Editing OAuth policies for an external client app.

2. In the OAuth Policies section, configure the following settings:

  • Select Enable Client Credentials Flow.
  • Specify the email address of the Salesforce user on whose behalf access tokens will be issued.

Configuring the client credentials flow and integration user.

3. Click Save.