How do External Credentials decouple authentication providers from endpoint configurations in modern Salesforce architecture?
Answer
Basics: Before Winter '23, a Named Credential combined URL and auth in one record, so ten endpoints on the same OAuth provider needed ten copies. The new model separates what to call (Named Credential: URL, headers) from how to authenticate (External Credential: protocol and principals), and separates who can use it (permission sets).
How it works:
- Create an Auth Provider or choose another protocol for the External Credential: OAuth 2.0 (browser flow or JWT bearer, client credentials), Basic, AWS Signature v4, Custom, and others.
- Add a Principal: Named Principal (shared identity, secrets stored in Salesforce) or Per User Principal (each user authorizes).
- Create one or more Named Credentials pointing to the External Credential and give each its base URL.
- Open a permission set and add External Credential Principal Access for the principal.
- Assign the permission set to the users or integration user whose Apex or Flow makes the call.
- At callout time Salesforce checks the user's principal access, builds the auth header and sends the request.
Advanced / deep dive: The principal-access check is an extra security layer: even an admin cannot call the endpoint through Apex unless granted. Custom headers can reference the credential parameters (formulas like {!$Credential.<ExternalCredentialName>.<ParameterName>}), which suits APIs needing API keys plus a bearer token. Rotating a secret changes one external credential, not every endpoint. Authentication problems are isolated from URL problems, and sandbox refreshes need only the secret re-entered. Per-user principals preserve end-user identity downstream (audit, row-level security in the target) but need an onboarding step where each user authenticates; use named principals for system-to-system integration. Metadata for External Credentials deploys, but secrets do not.