Home / security / oauth-redirect-and-domain-strategy
oauth-redirect-and-domain-strategy
Design Connected App OAuth callback URLs, My Domain naming, Enhanced Domains cutover, and cross-environment redirect handling. Trigger keywords: oauth redirect uri, connected app callback, my domain, enhanced domains, sandbox url change. NOT for end-user login flow UX, Experience Cloud branding, or SAML-only SSO configuration — use admin/connected-app-troubleshooting.
Open the skill folder on GitHub
OAuth Redirect And Domain Strategy
Every OAuth failure in Salesforce that is not a permission problem is a string matching problem. Three strings have to line up, and they are owned by three different parties:
| String | Owned by | Where it lives |
|---|---|---|
| Login host | The org | https://<mydomain>.my.salesforce.com, or https://<mydomain>--<sandbox>.sandbox.my.salesforce.com |
redirect_uri | The client | Sent on the authorize request and again on the token request |
| Callback URL | The connected app | ConnectedAppOauthConfig.callbackUrl — "It's the OAuth redirect_uri" |
The failure mode is binary and leaves almost no Salesforce-side evidence: a browser redirect carrying an error parameter, no debug log, and often nothing in Login History because no login occurred. Client-side logging is the primary diagnostic and has to exist before you need it.
Before Starting
- Enumerate the applications, not the orgs. One logical application deployed to
four environments is one connected app with four callback lines — not four connected apps.
- Know that the consumer key is immutable. "In API version 32.0 and later, you
can set this field's value only during creation. After you define and save the value, it can't be edited." It must also be globally unique.
- Establish whether clients can send PKCE before requiring it. Turning it on is
a hard cut: "any authorization code flow variations that don't implement it fail."
- Inventory what lives outside the org if a domain change is coming — IdP
configuration, webhook registrations, partner allow-lists. Their owners' lead time is the cutover's real critical path.
Core Concepts
callbackUrl is a newline-separated list
A Connected App accepts multiple callback URLs, newline-separated (\r programmatically), and matches the app's requested URL against the list at run time — quoted in full in