> ## Documentation Index
> Fetch the complete documentation index at: https://www.klavis.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Setting Up Salesforce OAuth App

> Complete guide to creating and configuring a Salesforce OAuth application

## Prerequisites

* Salesforce account (personal or business)
* Access to Salesforce Developer Portal

## Step 1: Create Salesforce Developer Account

1. Visit [https://developer.salesforce.com/](https://developer.salesforce.com/)
2. Click **"Sign Up"** or **"Login"** if you already have an account
3. Sign in with your Salesforce account or create a new developer account

<img src="https://mintcdn.com/klavisai/TEzGHGg1v0ZnLKee/images/knowledge-base/salesforce_oauth_app/salesforce_step1_login.png?fit=max&auto=format&n=TEzGHGg1v0ZnLKee&q=85&s=72befda1dbd5251e4e096bea033c40ec" alt="Salesforce Developer Login" width="1920" height="1080" data-path="images/knowledge-base/salesforce_oauth_app/salesforce_step1_login.png" />

## Step 2: Enable Connected Apps

1. Once logged in, go to **"Setup Menu"** (Gear Icon) and click **"Setup"**
2. Search **"External Client Apps"** in the **"Quick Find"** search box
3. In **"External Client App Settings"**, enable **"Allow creation of connected apps"**
4. Click **"New Connected App"**

<img src="https://mintcdn.com/klavisai/u0M5VtQWNN053zhM/images/knowledge-base/salesforce_oauth_app/salesforce_step2_create_app.png?fit=max&auto=format&n=u0M5VtQWNN053zhM&q=85&s=983d9ba4083875c0688feae2b7881592" alt="Salesforce App Creation" width="1465" height="565" data-path="images/knowledge-base/salesforce_oauth_app/salesforce_step2_create_app.png" />

## Step 3: Fill Basic App Information

1. Fill the necessary app details:

   * **Connected App Name**: Your application name (e.g., your brand name)
   * **API Name**: Auto-generated from app name (only letters, numbers, and underscores allowed)
   * **Contact Email**: Your contact email for Salesforce support
   * **Contact Phone**: Your contact phone for Salesforce support
   * **Logo Image URL**: (Optional) HTTPS URL for your app logo (max 100 KB, preferably under 20 KB)
   * **Info URL**: (Optional) Web page with more information about your app
   * **Description**: (Optional) Up to 256 characters describing your app

   <img src="https://mintcdn.com/klavisai/u0M5VtQWNN053zhM/images/knowledge-base/salesforce_oauth_app/salesforce_step3_basic_info.png?fit=max&auto=format&n=u0M5VtQWNN053zhM&q=85&s=b9f34cfaa517f1d854fd682303e393af" alt="Basic App Information" width="1440" height="1004" data-path="images/knowledge-base/salesforce_oauth_app/salesforce_step3_basic_info.png" />

<Note>
  Klavis Salesforce MCP Server uses the following OAuth scopes: `api,refresh_token,offline_access`
</Note>

1. In the **API (Enable OAuth Settings)** section:
   * Select **"Enable OAuth Settings"**
   * **Callback URL**: Enter `https://api.klavis.ai/oauth/salesforce/callback`

2. **Select OAuth Scopes**: Move required scopes from **"Available OAuth Scopes"** to **"Selected OAuth Scopes"**:
   * `Manage User Data via APIs (api)` - required to manage user data via APIs
   * `Perform requests on your behalf at any time (refresh_token, offline_access)` - required to perform requests at any time

3. **Additional Settings**:
   * Enable **"Require Secret for Web Server Flow"** if your app can keep the client secret confidential
   * Enable **"Require Secret for Refresh Token Flow"**
   * Enable **"Enable Authorization Code and Credentials Flow"**
   * Disable **"Require PKCE Extension for Supported Authorization Flows"**

4. Click **"Save"** to create the app

## Step 4: Get Consumer Key and Secret

After creating the app, follow these steps to get the credentials.

1. From dashboard, go to **"Setup Menu"** (Gear Icon) and click **"Setup"**
2. Search **"App Manager"** in the **"Quick Find"** search box
3. Find your connected app in the list and click the dropdown arrow, then select **"View"**

<img src="https://mintcdn.com/klavisai/u0M5VtQWNN053zhM/images/knowledge-base/salesforce_oauth_app/salesforce_step4_view_connected_apps.png?fit=max&auto=format&n=u0M5VtQWNN053zhM&q=85&s=f3d17b50e32de76b0f363ca3d70fcc6a" alt="View Connected Apps" width="1718" height="1270" data-path="images/knowledge-base/salesforce_oauth_app/salesforce_step4_view_connected_apps.png" />

4. In the **API (Enable OAuth Settings)** section, click **"Manage Consumer Details"**
5. Verify your identity using the **verification code** sent to your email
6. Copy the **Consumer Key** and **Consumer Secret** (keep them secure!)

<img src="https://mintcdn.com/klavisai/u0M5VtQWNN053zhM/images/knowledge-base/salesforce_oauth_app/salesforce_step4_view_consumer_key_and_secret.png?fit=max&auto=format&n=u0M5VtQWNN053zhM&q=85&s=7126112b0d3ed3283119ef233794dea2" alt="Get Consumer Key and Secret" width="963" height="1025" data-path="images/knowledge-base/salesforce_oauth_app/salesforce_step4_view_consumer_key_and_secret.png" />

## (Optional) Step 5: White Labeling

<Note>
  White labeling allows you to customize the OAuth experience with your own branding instead of Klavis AI's.
</Note>

If you want to use your own Salesforce OAuth application with custom branding:

1. **Configure White Labeling**: Go to [https://www.klavis.ai/home/white-label](https://www.klavis.ai/home/white-label)
2. **Add Your Credentials**: Enter your Salesforce **Consumer Key** and **Consumer Secret** from Step 5
3. **Set Redirect URI**: Use `https://api.klavis.ai/oauth/salesforce/callback` or your custom callback URL
4. **Initiate OAuth**: Use your Client Id when starting the OAuth flow:

   <CodeGroup>
     ```javascript without SDK theme={null}
     // Example: Initiating Salesforce OAuth with white-label
     const authUrl = `https://api.klavis.ai/oauth/salesforce/authorize?instance_id=${instanceId}&client_id=${yourClientId}`;
     window.location.href = authUrl;
     ```

     ```typescript TypeScript SDK theme={null}
     import { Klavis } from "@klavis/sdk";

     const klavis = new Klavis({
       apiKey: "YOUR_API_KEY"
     });

     // Example: Initiating Salesforce OAuth with white-label
     const oauthUrl = await klavis.mcpServer.getOAuthUrl({
       serverName: Klavis.McpServerName.Salesforce,
       instanceId: instanceId,
       clientId: yourClientId,
       // redirectUri: YOUR_REDIRECT_URI,
       // scope: "YOUR_SCOPES", 
     });

     window.location.href = oauthUrl;
     ```

     ```python Python SDK theme={null}
     import webbrowser
     from klavis import Klavis
     from klavis.types import McpServerName

     klavis = Klavis(api_key="YOUR_API_KEY")

     # Example: Initiating Salesforce OAuth with white-label
     oauth_url = klavis.mcp_server.get_oauth_url(
         server_name=McpServerName.SALESFORCE,
         instance_id=instance_id,
         client_id=your_client_id,
         # redirect_uri="YOUR_REDIRECT_URI",
         # scope="YOUR_SCOPES"
     )

     # Open OAuth URL in user's default browser
     webbrowser.open(oauth_url)
     ```
   </CodeGroup>

<Tip>
  For detailed white labeling implementation and code examples, see our [OAuth & White Labeling guide](/auth/white-label).
</Tip>

## Resources

* [Salesforce Developer Documentation](https://developer.salesforce.com/docs)
* [Salesforce OAuth Authentication Guide](https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/code_sample_auth_oauth.htm)
* [Klavis OAuth & White Labeling Guide](/auth/white-label)
* [Klavis White Label Dashboard](https://www.klavis.ai/home/white-label)
* [Salesforce API Scopes Reference](https://developer.salesforce.com/docs/platform/mobile-sdk/guide/oauth-scope-parameter-values.html)
