AuthProvider configures an external authentication service for Salesforce single sign-on (SSO), account linking, or OAuth access to external services. It combines provider endpoints and credentials with optional user-registration logic implemented in Apex or a flow.
An authentication provider is not the same as a credential that authorizes every user's external API calls. Successful Salesforce login does not necessarily establish per-user integration authorization. Provider capabilities also differ: Bitbucket and GitHub support OAuth access to their APIs but cannot authenticate users into Salesforce, and MicrosoftACS does not support Salesforce SSO.
Key Elements
| Element | What the Element Controls |
|---|---|
providerType |
Required. Selects the external provider or protocol. Documented values include Apple, Bitbucket, Custom, Facebook, GitHub, Google, Janrain, LinkedIn, Microsoft, MicrosoftACS, MuleSoft, OpenIdConnect, Salesforce, Slack, and Twitter. |
consumerKey |
The app key registered with the external provider. Customizing a Salesforce-managed endpoint, scope, or credential setting requires both this key and consumerSecret. |
consumerSecret |
The external app's secret. Supply plaintext in declarative metadata. Exports contain a placeholder, not a recoverable secret. The field contract documents the value as unchangeable once set. |
registrationHandler |
An existing Apex class implementing Auth.RegistrationHandler. Use this or flow, not both. |
flow |
A flow of type Identity User Registration Flow. Omit registrationHandler when using a flow. |
executionUser |
The Salesforce username under which the registration class or flow runs. Required for either registration mechanism; the user must have Manage Users. |
flowDefaultProfile |
The default profile for flow-based registration. A default profile is required, but it can instead be configured inside the flow. The flow's setting takes precedence. |
flowDefaultAccount |
The default account for external-user registration. A default account is required when the registration flow creates or updates external users. A value configured inside the flow takes precedence. |
plugin |
An existing Apex class extending Auth.AuthProviderPluginClass for a custom authentication provider. This is separate from the registration handler. |
customMetadataTypeRecord |
Required for a custom authentication provider plug-in. Links the provider to its CustomMetadata configuration. |
requireMfa |
Requires multi-factor authentication (MFA) for SSO according to each user's MFA status. It does not trigger MFA unless MFA also applies directly to the user. |
includeOrgIdInIdentifier |
Stores the source org ID with the third-party user ID to distinguish identical IDs from different orgs. Applies only to Salesforce-managed providers. Once enabled, it cannot be disabled. |
isPkceEnabled |
Enables OAuth 2.0 Proof Key for Code Exchange (PKCE). Supported provider types are Custom, Facebook, Google, Microsoft, OpenIdConnect, and Salesforce. |
sendClientCredentialsInHeader |
Required as a configuration element for OpenIdConnect. When true, sends client credentials to tokenUrl in an HTTP header rather than a query string. |
paramForwardAllowlist |
Nested entries identifying URL parameters that can pass from client configuration URLs to the authorization URL. Supports at most 10 parameters. |
Behavior and Constraints
Administrative access and identity controls
Access to AuthProvider requires both Customize Application and Manage AuthProviders. These administrative permissions are separate from the Manage Users permission required by the user who executes registration logic.
Setting requireMfa alone is insufficient. MFA must also apply directly to the user through either the org setting "Require multi-factor authentication (MFA) for all direct UI logins to your Salesforce org" or the "Multi-Factor Authentication for User Interface Logins" user permission.
includeOrgIdInIdentifier addresses identities from different source orgs, such as two sandboxes whose users have identical third-party user IDs. Enabling it changes the stored identifier to include the source org ID. This Salesforce-managed-provider setting is irreversible.
Registration logic and execution context
Choose exactly one registration mechanism when registration logic is needed:
- For Apex, set
registrationHandlerto an existing class implementingAuth.RegistrationHandlerand omitflow. - For a flow, set
flowto an Identity User Registration Flow and omitregistrationHandler.
Either mechanism requires executionUser. Its value is a Salesforce username, not a user record ID or an Apex class name. The selected user supplies the registration handler's execution context and attribution for records it creates. The user must have Manage Users; use a system user in production.
A flow registration handler requires a default profile. It also requires a default account when creating or updating external users. Configure these through flowDefaultProfile and flowDefaultAccount, or inside the flow. Values inside the flow take precedence over the provider fields.
For the Authentication Provider User Registration standard flow, flowDefaultProfile populates defaultProfileId, and flowDefaultAccount populates defaultAccountId. The profile setting is associated with Profile metadata; the account setting identifies the account used for external-user registration.
For providerType set to Custom, plugin names an Apex class extending Auth.AuthProviderPluginClass, and customMetadataTypeRecord is required. The authentication plug-in handles the custom authentication extension point. It does not replace an Apex or flow registration handler, and a registration handler does not replace the plug-in.
Salesforce-managed configuration
Salesforce-managed configuration is available for Apple, Bitbucket, Facebook, GitHub, Google, Janrain, LinkedIn, Microsoft, MicrosoftACS, MuleSoft, Salesforce, and Slack.
To use managed defaults, leave all six of these settings blank at creation: authorizeUrl, consumerKey, consumerSecret, defaultScopes, tokenUrl, and userInfoUrl. Salesforce supplies and manages their values.
Supplying any one of those settings requires supplying both consumerKey and consumerSecret. This applies even if the intended customization is only an endpoint or scope change. Blank managed settings are not, by themselves, evidence of incomplete configuration. The creation-time defaulting rule does not establish that clearing an existing value resets it to a managed default.
OpenID Connect endpoints and token handling
For OpenIdConnect, include authorizeUrl and sendClientCredentialsInHeader. The first identifies the OAuth authorization endpoint. tokenUrl identifies the token endpoint, and userInfoUrl identifies the user-information endpoint.
The two header settings control different exchanges:
-
sendClientCredentialsInHeadersends client credentials totokenUrlin an HTTP header whentrue, rather than in a query string. Its Basic credentials format isBasic <token>, where the token is the base64-encoded stringclientkey:clientsecret. This describes HTTP transport formatting, not how to serializeconsumerSecretin metadata. -
sendAccessTokenInHeadersends the access token touserInfoUrlin a header whentrue, rather than in a query string.
For OpenID Connect, defaultScopes supplies authorization-request scopes only when scopes are not specified as the authorization flow starts. It does not unconditionally override scopes on every request.
For OpenIdConnect and Microsoft, idTokenIssuer is an HTTPS URI identifying the token source. When supplied, Salesforce validates the returned id_token. OpenID Connect requires an id_token to be returned with the access_token.
Other provider requirements and URLs
-
ApplerequiresappleTeam, a 10-character Apple developer team ID, andecKey, an Apple-generated private key. -
MuleSoftrequirescontrolPlane. Allowed values areUS,EU, andNone.Nonemeans a user-specified control plane and requires the key and secret from the MuleSoft connected app. The control plane determines the login URL. - Each
paramForwardAllowlistentry uses the nestedAuthProvParamFwdAllowliststructure:paramnames the URL parameter, anddescriptionexplains it. Parameters such asui_localesandlogin_hintare examples, not required entries.
ssoKickoffUrl, linkKickoffUrl, and oauthKickoffUrl are read-only entry points for Salesforce SSO, linking an existing Salesforce user to a third-party account, and obtaining third-party OAuth tokens, respectively. They are not interchangeable with the configurable authorization and token endpoints.
logoutUrl specifies where an SSO-authenticated user goes after logging out. It must be a fully qualified URL beginning with http or https.
Deployment and Retrieval
Authentication providers are stored in the authproviders directory with the .authprovider extension. The file base name matches the provider's URL suffix. For example, URL suffix FacebookProvider corresponds to authproviders/FacebookProvider.authprovider. The required friendlyName is the user-facing name, not the sole component identifier.
In package.xml, use AuthProvider as the metadata type and the provider's URL suffix as the member name. The type supports the wildcard member * for manifest-based retrieval.
Retrieved metadata is not a transferable credential backup. Supply consumerSecret as plaintext in declarative metadata. When a defined secret is exported, Salesforce returns a placeholder rather than a recoverable encrypted secret, regardless of sendSecretInApis. This applies when interpreting retrieved metadata or a change-set export: the exported value does not provide the original credential for another org.
The Metadata API field contract documents consumerSecret as unchangeable once set. Do not treat redeploying a changed secret as a supported secret-rotation mechanism.
For deployment with registration logic, executionUser must resolve as a username in the destination org. Matching user record IDs across a sandbox and production do not satisfy this dependency if the usernames differ. The referenced registration class or flow must also exist, as must the custom plug-in and custom metadata configuration when using a custom provider.
Metadata API support does not imply support for Apex data manipulation language (DML), such as insert or delete, on the similarly named runtime AuthProvider sObject. Community reports distinguish API-based administration from rejected Apex DML operations; those failures do not establish a lack of metadata deployment support.
Relationships
AuthProvider references registration and authentication implementations, configuration, and a default profile. Other metadata types can consume the provider for external access or message handling. These consumers are not contained within the provider, and a provider's actual impact depends on which references are populated.
References
-
ApexClass:plugin,registrationHandler. -
CustomMetadata:customMetadataTypeRecord. -
Flow:flow. -
Profile:flowDefaultProfile. -
Portal:portal. This applies to existing deprecated portals, not registration-flow configuration. Salesforce does not support creating new portals.
Separately, executionUser is a username dependency, not an ApexClass reference. flowDefaultAccount identifies the account used for external-user registration.
Referenced By
-
ConversationMessageDefinition:handlerName. -
ExternalCredential:authProvider. -
ExternalDataSource:authProvider. -
NamedCredential:authProvider.
Documentation Inconsistencies
The consumerSecret field description includes encrypted-input language for create() and a change-set procedure for obtaining an encrypted value. The declarative metadata instructions instead specify plaintext, and the explicit export rule states that exports contain only a placeholder. For declarative deployments, supply plaintext; do not interpret an exported value as a reusable encrypted credential.
The sendSecretInApis description says the setting controls encrypted-secret inclusion or omission and associates disabling it with change-set and metadata deployment failures. That conflicts with the explicit rule that the secret is always exported as a placeholder regardless of this setting. Enabling the flag does not make retrieval a credential backup.
The general type description includes GitHub as a Salesforce login example, but the provider-specific definition explicitly says GitHub is not an SSO provider. Use it for OAuth access to GitHub APIs, not Salesforce login.
Reported Issues
-
A deployment can fail because the execution username does not exist in the destination. In a 2017 sandbox-to-production report, the user IDs matched but the usernames differed, causing a missing-user failure for
executionUser. This was a username-resolution problem, not proof that registration handlers cannot be deployed. Execution-user deployment report. -
Successful sign-in may leave per-user callouts unauthorized. In a custom-provider community-login configuration with a per-user
NamedCredential, a 2022 answer reported that users still needed the external-system OAuth authorization flow. Creating anExternalDataUserAuthrecord alone did not authorize access. This finding concerns that configuration, not every credential model. Per-user authorization discussion. -
Apex insertion can be rejected even when an API supports creation. A 2024 report described rejected
insertDML on the runtimeAuthProvidersObject. The answer recommended REST or Metadata API administration instead. This is separate from deployingAuthProvidermetadata. Apex creation report. -
Apex deletion can be rejected even when API deletion is documented. A 2019 report described rejected
deleteDML on the runtime sObject. The answer suggested an API call where the execution context permits it, rather than direct Apex DML. Apex deletion report. - Source-tracking retrieval can fail while explicit retrieval succeeds. In a 2019 report, a source pull could not find an authentication provider. One answer reported that explicit retrieval worked and that replacing spaces with underscores in the name and URL suffix resolved subsequent pull failures. Treat this as a reported naming-related diagnostic, not a universal retrieval restriction. Provider retrieval discussion.
Common Questions
Can I retrieve an AuthProvider consumer secret and deploy it to another org?
No. A defined consumerSecret is exported as a placeholder, regardless of sendSecretInApis. Supply plaintext for declarative configuration that requires the secret; retrieval does not recover the original credential.
Why does my AuthProvider deployment say the execution user cannot be found?
executionUser resolves by Salesforce username in the destination org, not by record ID. Sandbox and production usernames can differ even when the user IDs match. The destination user must also have Manage Users.
Can an AuthProvider use both an Apex registration handler and a flow?
No. Use registrationHandler for an Apex class implementing Auth.RegistrationHandler, or flow for an Identity User Registration Flow. Omit the other element. Either option requires executionUser.
Does requireMfa force MFA for every SSO user?
Not by itself. MFA must also apply directly to the user through the direct-UI-login MFA org setting or the "Multi-Factor Authentication for User Interface Logins" user permission.
Why do external API calls fail after a user logs in through the same AuthProvider?
Salesforce login and per-user external API authorization are separate concerns. In the reported custom-provider and per-user credential configuration, users still needed to complete the external-system OAuth authorization flow; creating an ExternalDataUserAuth record alone was insufficient.