Get credentials for OAuth authentication

OAuth 2.0 (Open Authorization 2.0) is an authorization framework that allows third-party applications to access user resources without exposing user credentials.

For user-based authentication, OAuth 2.0 requires users to sign in through a browser and authorize the application’s access to their data. After authorization, the application can use a refresh token to obtain new access tokens without requiring users to sign in again.

Salesforce provides two options for configuring OAuth authentication:

  • Connected Apps - Support user-based authentication, where users sign in through a browser, grant access to their data, and allow the application to obtain OAuth tokens, such as access and refresh tokens.
  • External Client Apps - Support multiple OAuth authentication flows, including user-based and server-to-server authentication. They provide additional control over OAuth flows, client secret requirements, and token issuance policies.

Create a connected app in Salesforce

To create a connected app for OAuth authentication:

1. Sign in to Salesforce and navigate to Setup.

2. In the Quick Find box, enter App Manager, then select App Manager.

Creating a connected app in Salesforce App Manager.

3. Click New Connected App.

4. In the dialog box that opens, select Create a Connected App, then click Continue.

Selecting the Create a Connected App option.

5. In the Basic Information section, specify the following:

  • Connected App Name - Enter a name for your application. This name is displayed to users during authentication.
  • API Name - Review the API name generated automatically from the application name.
  • Contact Email - Enter an email address for support inquiries and notifications.

Configuring connected app details in Salesforce App Manager.

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

7. In the Callback URL field, enter:

https://oauth.devart.com/callback/57997

Note

You can also add callback URLs with ports 58997 and 59997.

8. Under Selected OAuth Scopes, select the required permissions and click Add. Commonly used scopes include:

  • Perform requests at any time (refresh_token, offline_access) - Allows the application to obtain new access tokens without requiring the user to sign in again.
  • Manage user data via APIs (api) - Allows the application to access Salesforce APIs.
  • Access and manage your data (full) - Grants broad access to Salesforce resources available to the authorized user.

9. Click Save to create the connected app.

Obtain OAuth client credentials for a connected app

To obtain the Client ID and Client Secret:

1. In Salesforce Setup, open App Manager.

2. Locate your connected app, open its action menu, and select View.

3. Next to Consumer Key and Secret, click Manage Consumer Details.

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

The Consumer Key and Consumer Secret of a Salesforce connected app.

Create an external client app in Salesforce

To create an external client app for OAuth authentication:

1. Sign in to Salesforce and navigate to Setup.

2. Go to Apps > External Client Apps > External Client App Manager, then click New External Client App.

Creating a new external client app in Salesforce.

3. In the Basic Information section, enter the required application details.

4. In the Distribution State field, select Local.

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

6. In the Callback URL field, enter:

https://oauth.devart.com/callback/57997

Note

You can also add callback URLs with ports 58997 and 59997.

7. Add the following OAuth scopes:

  • Manage user data via APIs (api)
  • Perform requests at any time (refresh_token, offline_access)

Configuring OAuth settings for an external client app.

8. In the Flow Enablement section, select the option appropriate for your authentication scenario:

  • Enable Authorization Code and Credentials Flow - For user-based authentication.
  • Enable Client Credentials Flow - For server-to-server authentication.

9. In the Security section, configure the settings based on the selected authentication method:

For user-based authentication:

  • Select Require secret for Web Server Flow.
  • Select Require secret for Refresh Token Flow.

For server-to-server authentication:

  • Clear all checkboxes in the Security section.

Configuring OAuth security settings for an external client app.

10. Click Create.

Configure an external client app for the OAuth 2.0 client credentials flow

Server-to-server authentication uses the OAuth 2.0 client credentials flow to obtain an access token without interactive user sign-in. The application authenticates using its Client ID (Consumer Key) and Client Secret (Consumer Secret).

You must also specify an integration user whose permissions determine which Salesforce data the application can access.

To configure the client credentials flow:

1. Open the external client app you created.

2. Open the Policies tab and click Edit.

3. In the OAuth Policies section, select Enable Client Credentials Flow.

4. Specify the user on whose behalf access tokens will be issued.

5. Click Save.

Configuring the integration user for the client credentials flow.

Obtain OAuth client credentials for an external client app

To obtain the Client ID and Client Secret:

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

2. Locate and open your external client app.

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

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