Guides / n8n × Salesforce / Authentication

Setting up a Salesforce Connected App for API access

External Client App or legacy Connected App, the PKCE and Require Secret combinations that differ between them, the scopes an integration actually needs, and the propagation delay that makes a correct setup look broken.

Illustrated troubleshooting diagram for How to set up a Salesforce Connected App for API access.
OAUTH_APPROVAL_ERROR_GENERIC on the Salesforce approval page, or redirect_uri_mismatch, before any credential is ever evaluated.
Short answer: Create an External Client App rather than a legacy Connected App for new integrations, and configure it for the flow your client actually performs: for an External Client App enable Require PKCE and Require Secret for both the Web Server and Refresh Token flows; for a legacy Connected App disable all three. Request api, refresh_token and offline_access. Set the callback URL to the byte-exact value your client sends. Then wait — Salesforce takes several minutes to propagate app changes and around ten minutes before a new app accepts any authorization, and an instant retry reproduces the failure for no reason.

Pick the app type first, because the checkboxes differ

Salesforce now offers External Client Apps alongside the legacy Connected App, and this is the single most common source of setup failure — not because either is hard, but because checklists written for one are applied to the other. The two types expose similarly-named settings that must be set to opposite values for the same client to work.

For a new integration, create an External Client App. It is the current model, and some org-level restrictions introduced in recent Salesforce releases apply only to legacy Connected Apps. If you are maintaining an existing legacy app, keep it, but follow the legacy row below rather than the current one.

Settings that must differ between the two app types

SettingExternal Client AppLegacy Connected App
Require PKCEEnabledDisabled
Require Secret for Web Server FlowEnabledDisabled
Require Secret for Refresh Token FlowEnabledDisabled
Where it livesSetup → External Client AppsSetup → App Manager

Scopes: three, for almost every integration

An API integration needs api to call the REST endpoints, refresh_token to obtain a refresh token at all, and offline_access so that token keeps working when no user session is active. Omitting refresh_token produces a connection that works during setup and dies at the first access-token expiry, typically overnight — which reads as an intermittent credential fault and is not one.

full is broader than almost anything needs and is worth avoiding on principle; it grants everything the authenticating user can do. Add narrower scopes as specific features require them rather than starting wide.

Callback URL and permitted users

The callback URL must match what the client sends byte for byte — scheme, host, port, path, trailing slash. A mismatch produces redirect_uri_mismatch before anything else is evaluated, and the usual culprits are http versus https, a trailing slash on one side only, and a host that differs from the one the client is actually reached at behind a proxy.

Under OAuth policies, Permitted Users controls who can authorize the app. Set to "Admin approved users are pre-authorized", the user attempting to connect must be explicitly granted access through a profile or permission set assigned to the app — otherwise the approval page fails outright rather than showing a friendly authorization message. "All users may self-authorize" avoids that during setup and should be reconsidered before production.

# Reproduce the approval page outside your client — isolates app config
# from client config in one request.
https://login.salesforce.com/services/oauth2/authorize
  ?response_type=code
  &client_id=3MVG9...                  # Consumer Key from the app
  &redirect_uri=https://n8n.example.com/rest/oauth2-credential/callback
  &scope=api%20refresh_token%20offline_access
  &prompt=login

# Fails here too -> app config: scopes, PKCE, permitted users, propagation
# Works here     -> the app is fine; the difference is what the client sends

# Sandbox? The host must match the org the app lives in:
#   https://test.salesforce.com/services/oauth2/authorize
#   https://acme--uat.sandbox.my.salesforce.com/services/oauth2/authorize

Wait before you conclude it is broken

Salesforce documents that Connected App and OAuth policy edits take several minutes to propagate, and a newly created app can take around ten minutes before it accepts any authorization at all. An immediate retry after saving reproduces the original error with complete reliability, which sends people back to change a setting that was already correct.

Test in a private browser window. A partially completed OAuth session in a normal window produces confusing results on retry — Salesforce reuses the existing session and the failure appears to move around.

Change one variable at a time when it still fails. Dropping the scope parameter tests whether an ungranted scope is the trigger. Adding code_challenge and code_challenge_method=S256 tests the PKCE requirement from the other side: if the app requires PKCE, the bare URL fails and the PKCE version succeeds, which identifies the mismatch in one step.

An app created in a sandbox exists only in that sandbox. Its Consumer Key is not valid against login.salesforce.com, and the resulting failure is generic rather than a clear unknown-client message.

Verify you reached the org you meant to

One request after connecting settles the question that causes the most expensive mistakes. The userinfo endpoint returns the organization_id and the instance URLs for the token you hold, and a sandbox org ID differs from production's. Checking it costs nothing and prevents a workflow that believes it is writing to a sandbox from writing to live data.

Record the app type, Consumer Key, scope list, callback URL, permitted-users setting and the org it lives in. Every one of those is a thing someone will need to check during the next incident, and none of them is discoverable from the client side.

  • App type chosen, and PKCE/Require Secret set to match that type.
  • Scopes: api, refresh_token, offline_access.
  • Callback URL byte-identical to what the client sends.
  • Authorizing user permitted, via profile or permission set if pre-authorization is on.
  • Waited 5–10 minutes after saving before retrying.
  • userinfo confirms the expected organization_id.

The integration user is part of the setup

An app grants the right to connect; the user it connects as decides what that connection can actually do. A Connected App configured perfectly, authorised by a user whose profile cannot edit a field, produces failures that look like app misconfiguration and are not — REQUIRED_FIELD_MISSING on a field the payload contained is the classic symptom, because field-level security dropped the value before validation ran.

Authorise as a dedicated integration user rather than as whoever happened to set it up. A named person's account carries their profile, their role's record visibility and their personal settings, and it stops working when they leave — taking every integration built on it with it, usually on a day nobody expected.

Give that user a profile or permission set built for the job: the objects and fields the integration touches, the record visibility it needs, API Enabled, and View Setup and Configuration if anything reads the Limits resource. Then verify by running a describe with the integration's own token rather than an admin's, since the describe response is permission-aware and an admin's view of it hides exactly the problems you are looking for.

Where these facts come from