Skip to main content
No Result Found
Connect & Get help from 6000+ developers on our Discord community. Ask the CommunityAsk the Community

Create a connected app

Learn how to create a Salesforce connected app to securely connect your Salesforce environment to BrowserStack Salesforce Test Automation.

To enable seamless, automated test execution, you need to connect your Salesforce environment to BrowserStack’s Salesforce Test Automation. This guide walks you through creating a Connected App (or External Client App) in Salesforce to securely generate a Client ID and Client Secret, and how to assign the correct user for execution.

Prerequisites

To connect Salesforce and fetch the necessary metadata, the user account authenticating the connection must have the following permissions:

  1. API Enabled: Allows API access to Salesforce
  2. View Setup and Configuration: Enables viewing of setup and configuration settings
  3. Modify Metadata Through Metadata API Functions: Permits metadata modifications
  4. View All Data: Grants read/write access to all data (or explicit access to specific objects you intend to test)

Choose a user account

You can use one of the following options to set up the connection:

  • Option 1 (Recommended): Use an existing System Administrator account, which already has all required permissions.
  • Option 2: Use an existing Standard User account, provided you assign them a Permission Set or Profile containing the required permissions.
  • Option 3: Create a dedicated Integration User account specifically for testing and assign the required permissions.

If you create a dedicated Integration User, you must complete the additional step to set the Run As execution user in Step 2.

Step 1: Create the connected app in Salesforce

The connected app acts as the secure bridge between your Salesforce environment and BrowserStack Test Automation. Only a Salesforce System Administrator can create this app.

To create the connected app:

  1. Log in to your Salesforce org.
  2. Click the Gear icon (⚙) in the top right and select Setup.

    The Salesforce gear icon menu with Setup option highlighted

  3. In the Quick Find box, type External client app manager and select it from the results.
  4. Click the New External Client App button in the top right corner.

    The External Client App Manager page with New External Client App button highlighted

  5. Fill in the basic information:
    • Connected App Name: Enter BrowserStack Test Automation or a similar descriptive name.
    • API Name: Auto-populates based on the app name.
    • Contact Email: Enter your email address.

    The New External Client App form showing app name and contact email fields

  6. Scroll down to API (Enable OAuth Settings) and check the box for Enable OAuth.

    The API Enable OAuth Settings checkbox highlighted

  7. In the Callback URL field, enter the following URL exactly as shown:
    https://elca-api.browserstack.com/api/v1/sfdc-auth/callback
    
  8. Under Selected OAuth Scopes, add the following scopes by moving them from the Available OAuth Scopes column to the Selected OAuth Scopes column:
    • Access the identity URL service (id, profile, email, address, phone)
    • Manage user data via APIs (api)
    • Manage user data via Web browsers (web)
    • Perform requests at any time (refresh_token, offline_access)

    The OAuth settings showing callback URL and selected OAuth scopes

  9. Click Save.

Salesforce takes 2 to 10 minutes for a new app to propagate across its servers. Attempting to connect immediately may result in an error. Wait at least 5 minutes before proceeding to Step 4.

Step 2: Set the Run As execution user

This step is only required if you created a dedicated Integration User in the prerequisites. If you’re using a System Administrator or Standard User account, skip this step and proceed to Step 3.

Because this app runs automated tasks in the background, you must specify which user account Salesforce should use to execute API calls.

To set the execution user:

  1. In the External Client App Manager, find your newly created app and click on it.
  2. Click the Edit button inside the Policies section. The External Client App page showing the Edit button in the Policies section
  3. Expand OAuth Policies.
  4. Under OAuth Flows and External Client App Enhancements, enable Client credentials flow. The OAuth Policies section showing Client credentials flow enabled and Run As field
  5. Under Run As, enter the username of your dedicated Integration User.
  6. Click Save.

Step 3: Retrieve your client ID and client secret

To retrieve your credentials:

  1. In the External Client App Manager, find your app and click on it.
  2. Navigate to the Settings tab.
  3. Expand OAuth settings and click the Consumer Key and Secret button. Salesforce emails you a verification code to access this screen.

    The OAuth settings with Consumer Key and Secret button highlighted

  4. Enter the verification code when prompted.
  5. Once verified, you see your Consumer Key (Client ID) and Consumer Secret (Client Secret).
  6. Click Copy next to both values and save them securely. Keep this tab open as you’ll need these values in the next step.

    The Consumer Key and Consumer Secret values with Copy buttons

Step 4: Connect your org in BrowserStack

Now that you have your Client ID and Client Secret, you can complete the connection in BrowserStack Test Automation.

To connect your Salesforce org:

  1. Open the BrowserStack Test Automation dashboard.
  2. Go to Settings and click + New Organisation.
  3. Select the Connected App option.

    The Connect Salesforce screen showing Connected App option

  4. Fill in the following details:
    • Environment type: Select whether this is a Sandbox or Production org. Always test on a Sandbox environment first before connecting to Production.
    • Organisation Name: Enter a user-friendly name to identify your org (for example, BrowserStack Sandbox).
    • Client ID: Paste the Consumer Key you copied from Step 3.
    • Client Secret: Paste the Consumer Secret you copied from Step 3.
  5. Click Connect.
  6. In the Salesforce OAuth page that opens, enter your Salesforce credentials and click Login. The connection is established, and you’re redirected back to BrowserStack Test Automation.

Your Salesforce org is now securely connected, and you’re ready to start building and executing automated tests.

Troubleshooting

If you encounter issues during the connection process:

  • Error: “Invalid client credentials”: Verify that you copied the correct Client ID and Client Secret from Salesforce. Ensure there are no extra spaces or characters.
  • Error: “Callback URL mismatch”: Confirm the callback URL in your connected app exactly matches: https://elca-api.browserstack.com/api/v1/sfdc-auth/callback
  • Error: “Insufficient privileges”: Ensure the user account has all four required permissions listed in the Prerequisites section.
  • Connection times out: Wait at least 5-10 minutes after creating the connected app in Salesforce before attempting to connect, as it takes time for the app to propagate across Salesforce servers.

Next steps

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle