Why sandbox logins are supposed to go through test.salesforce.com
Production Salesforce orgs authenticate through login.salesforce.com. Every sandbox type — Developer, Developer Pro, Partial Copy, and Full — is a separate org with its own OAuth endpoint at test.salesforce.com, not a subset of production. This is standard Salesforce platform behavior, not something specific to n8n: any OAuth-based integration pointed at login.salesforce.com for a sandbox org will fail or authenticate against the wrong org entirely.
n8n's Salesforce credential includes an "Environment Type" setting specifically so it can send the OAuth authorization request to the correct endpoint (test.salesforce.com for Sandbox, login.salesforce.com for Production). A user on n8n Cloud reported that with Environment Type correctly set to Sandbox, the popup still opened login.salesforce.com for a Developer-license sandbox — while the same instance and credential type connected without issue to a Partial Copy sandbox. That's a strong signal the Sandbox setting isn't being honored consistently for every sandbox license type, rather than anything wrong with how the credential was filled in.
If your Partial Copy or Full sandbox connects fine through n8n but a Developer-license sandbox specifically fails with a login.salesforce.com popup, this matches a reported bug pattern — not a configuration mistake to keep hunting for.
Confirm you're looking at this exact pattern before troubleshooting further
Distinguish this from the two failures it resembles before doing anything else, because they have different fixes. A redirect_uri mismatch produces an explicit error message naming the redirect URI, and it happens after Salesforce has identified the app. OAUTH_APPROVAL_ERROR_GENERIC happens after a successful login, when the app's policy refuses the authorization. This problem is earlier than both: the popup opens the wrong domain before any login form appears.
Confirm the host in the address bar of the popup, not in the credential form. If the URL begins with https://login.salesforce.com/services/oauth2/authorize while Environment Type is set to Sandbox, the host is wrong and nothing about scopes, callback URLs, or permissions is relevant yet. If it begins with https://test.salesforce.com or with the sandbox My Domain, the host is right and your problem is one of the other two.
Check the username at the same time. A sandbox copies production usernames and appends the sandbox name, so a production user of ada@example.com logs into a sandbox called uat as ada@example.com.uat. Entering the production username on the sandbox login page fails with an ordinary bad-credentials message that is easy to misread as an OAuth problem.
- Redirect URI is confirmed correct in the Connected App and matches n8n's generated OAuth Redirect URL exactly.
- Environment Type in the n8n credential is set to Sandbox, not Production.
- The same n8n instance and credential type connects successfully to a Partial Copy or Full sandbox — isolating the failure to the Developer license specifically.
- Manually logging into the sandbox in a browser (outside of n8n) works normally through test.salesforce.com.
What to actually do about it right now
There is no confirmed fix published for this specific bug as of this writing. The practical options, in order of effort:
First, check your n8n version against the Community thread's reported version (n8n Cloud 1.121.3) and against n8n's release notes for any Salesforce-credential fix mentioned after that version — if you're on a materially newer release and haven't retested, do that before anything else. Second, if a Developer sandbox isn't a hard requirement for what you're testing, use a Partial Copy or Full sandbox instead, since those are reported to connect normally. Third, if you depend specifically on a Developer sandbox, file (or add a reply/vote to) the existing Community report so it stays visible to n8n's maintainers, rather than opening a fresh duplicate thread that fragments the report.
The reliable path: a Generic OAuth2 credential with explicit hosts
A Generic OAuth2 credential lets you type the authorization and token URLs yourself, which takes the Environment Type toggle out of the flow completely. Use the sandbox My Domain host rather than test.salesforce.com where you have it — Salesforce has been steadily moving orgs onto My Domain-only authentication, and the My Domain host is unambiguous about which sandbox you are reaching, where test.salesforce.com relies on the username suffix to route you.
The sandbox My Domain follows a fixed shape: the production My Domain, two hyphens, the sandbox name, then .sandbox.my.salesforce.com. A production org at acme.my.salesforce.com with a sandbox named uat authorizes at https://acme--uat.sandbox.my.salesforce.com. Both the authorization and the token endpoint live under that host, and the Connected App used must be the one that exists in the sandbox — a sandbox refresh copies the app, but its consumer key is the sandbox copy's, and reusing the production consumer secret is a common cause of a failure one step later.
After connecting, verify which org you actually reached rather than assuming. A call to the userinfo endpoint returns the organization_id and the instance URLs, and a sandbox org id is distinct from production's. This check takes one request and prevents the worst outcome available here, which is a workflow that believes it is writing to a sandbox and is writing to production.
- Generic OAuth2 credential, Authorization URL: https://yourdomain--sbx.sandbox.my.salesforce.com/services/oauth2/authorize
- Access Token URL: the same host with /services/oauth2/token
- Reuse the Connected App's Client ID, Client Secret, Callback URL, and scopes unchanged.
- A sandbox refresh changes the sandbox name and thus the host - update the credential after any refresh.
# Generic OAuth2 credential — sandbox My Domain, typed explicitly
Authorization URL:
https://acme--uat.sandbox.my.salesforce.com/services/oauth2/authorize
Access Token URL:
https://acme--uat.sandbox.my.salesforce.com/services/oauth2/token
Scope:
api refresh_token offline_access
Auth URI Query Parameters:
prompt=login # forces the account chooser instead of silently
# reusing whatever session the browser already has
# test.salesforce.com also works, and routes by the username suffix:
# https://test.salesforce.com/services/oauth2/authorize
# username: ada@example.com.uat <- sandbox name appended
# Verify you reached the sandbox and not production:
GET https://acme--uat.sandbox.my.salesforce.com/services/oauth2/userinfo
Authorization: Bearer ACCESS_TOKEN
# -> {"organization_id":"00D...","urls":{"custom_domain":"https://acme--uat.sandbox..."}}
Every sandbox refresh invalidates this connection
A refresh replaces the sandbox org with a new copy of production, and the connection you built does not survive it. Refresh tokens issued against the old copy stop working, the Connected App in the sandbox is a fresh copy with its own consumer key, and any integration user you created by hand in the sandbox is gone unless it also exists in production. The failure after a refresh therefore looks like a credential problem and is really an environment that no longer exists.
Plan the reconnection as part of the refresh rather than discovering it afterwards. Keep a short checklist: confirm the My Domain host still resolves, confirm the Connected App is present and note its consumer key, confirm the integration user is active and has the right profile and permission sets, then reauthorize the n8n credential and run one read-only call to verify. Doing this immediately after every refresh turns a recurring outage into a ten-minute task.
Never copy a production token into a sandbox credential to save time. Tokens are scoped to the org that issued them, so at best it fails immediately; at worst the credential is left pointing at production while everyone believes it is pointing at the sandbox, and the next test run writes live data.
How this was verified
The Production vs Sandbox OAuth endpoint distinction (login.salesforce.com vs test.salesforce.com) is standard, documented Salesforce OAuth behavior referenced in n8n's Salesforce credentials documentation. The specific Developer-license sandbox failure pattern, the n8n Cloud version it was reported on, and the fact that it remains unresolved with no staff response come directly from the original report on the n8n Community forum — nothing in this guide claims a fix beyond what that thread actually confirms.
Frequently asked questions
Does every Salesforce sandbox type use test.salesforce.com?
Yes — Developer, Developer Pro, Partial Copy, and Full sandboxes all authenticate through test.salesforce.com, never login.salesforce.com. This is Salesforce platform behavior, not specific to any integration tool.
My Partial Copy sandbox connects fine in n8n but my Developer sandbox doesn't — same n8n setup. Why?
This matches a reported, unresolved bug where n8n's Environment Type = Sandbox setting has not correctly routed Developer-license sandboxes to test.salesforce.com in at least one confirmed case (n8n Cloud 1.121.3). It is not something you misconfigured — check the confirm-the-pattern checklist above before assuming it's your setup.
Is there a confirmed fix I should apply?
Not as of this writing — the original Community report has no staff response or confirmed fix. Check whether your n8n version is newer than the one it was reported on (1.121.3), and if a Developer sandbox isn't a hard requirement, testing against a Partial Copy or Full sandbox instead is the most reliable path forward today.
Which username do I use on the sandbox login page?
The production username with the sandbox name appended — ada@example.com becomes ada@example.com.uat for a sandbox named uat. The production username alone fails with a credentials error that is easy to mistake for an OAuth problem.
How do I prove I connected to the sandbox and not production?
Call /services/oauth2/userinfo with the access token and read organization_id and the custom_domain URL. A sandbox org has a different org id from production, so this single request removes any doubt before the workflow writes anything.