ConnectedApp defines an external application's integration identity and authentication configuration for Salesforce APIs, OAuth authorization, OpenID Connect sign-in, SAML single sign-on (SSO), and Canvas apps embedded in Salesforce. It combines protocol configuration with user authorization, token, IP, and session policies. These settings control different layers: identifying the client, authorizing users, issuing tokens, and controlling later access.
Creation of new connected apps is restricted. Existing connected apps can continue to be used. Salesforce recommends external client apps for new integrations; creating another connected app requires contacting Salesforce Support.
Key Elements
| Element | What the Element Controls |
|---|---|
fullName |
The metadata component's identity. It is not the OAuth client ID or an installed application's record ID. |
label, contactEmail
|
Required app name and support contact email address. |
oauthConfig.consumerKey, oauthConfig.consumerSecret
|
The OAuth client_id and client_secret. Custom values can be set only during creation. Metadata API does not return the saved secret. |
oauthConfig.callbackUrl |
The registered OAuth redirect_uri. Multiple callback URLs must be separated by line breaks. |
oauthConfig.isAdminApproved |
false, the default, permits user self-authorization. true restricts access to users authorized through profiles or permission sets. |
profileName, permissionSetName
|
Access assignments requiring isAdminApproved=true. Explicitly empty strings have assignment-removal semantics during deployment. |
oauthConfig.scopes |
Authorized resources. Full covers only data accessible to the logged-in user; RefreshToken concerns refresh-token eligibility. |
oauthConfig.isClientCredentialEnabled, oauthConfig.oauthClientCredentialUser
|
Enable client credentials flow and select its execution user. A consumerKey is required, and the user must have the API Only permission. |
oauthConfig.isPkceRequired |
Requires Proof Key for Code Exchange (PKCE), which ties an authorization-code exchange to the client that started it. Configured authorization-code flow variations fail if they do not implement PKCE. |
oauthConfig.isRefreshTokenRotationEnabled |
Issues a replacement refresh token on each exchange. Reuse of an invalidated previous token deletes the current refresh token and its associated access tokens. |
oauthPolicy.refreshTokenPolicy |
Refresh-token validity: zero, infinite, specific_lifetime:number:UNIT, or specific_inactivity:number:UNIT. UNIT is HOURS, DAYS, or MONTHS. |
oauthPolicy.ipRelaxation, ipRanges
|
Combined IP-access behavior. Policy values are ENFORCE, BYPASS, ENFORCE_RELAXREFRESH, and BYPASS_2FACTOR. |
sessionPolicy |
Session timeout and High Assurance access requirements through sessionTimeout, sessionLevel, and policyAction. Actions are Block and RaiseSessionLevel. |
samlConfig |
Salesforce identity-provider settings for an external service provider, including its endpoints, user identifier, signing algorithm, and assertion encryption. |
canvasConfig, plugin, pluginExecutionUser
|
Canvas placement and authentication, custom connected-app authorization behavior, and the plugin execution user. Canvas lifecycle handlers and connected-app plugins use different Apex interfaces. |
Behavior and Constraints
User authorization and scopes
With oauthConfig.isAdminApproved=false, users must approve the app on first access. With true, only users with an authorized profile or permission set can access it, and those users do not approve it themselves. This setting is unavailable in Group Edition.
Assignment names alone do not establish effective access. Access also depends on the user's actual assignments and applicable session policies. Connected-app consumers can edit isAdminApproved when deploying the app in their org.
OAuth scopes describe authorized resources, not unrestricted access to Salesforce data. In particular, Full means all data accessible to the logged-in user. RefreshToken and OfflineAccess allow a refresh token to be returned when the user is eligible to receive one.
OAuth flow controls
Several independent switches affect authentication. Changing one does not replace the others:
-
isClientCredentialEnabled=truerequiresoauthClientCredentialUserandconsumerKey. Salesforce issues access tokens on behalf of that execution user, who must have the API Only permission. -
isPkceRequired=truerequires PKCE for configured authorization-code flow variations, including the web server flow and Authorization Code and Credentials Flow. Variations without PKCE fail. Salesforce recommends PKCE for both public and private clients. -
isConsumerSecretOptionalcontrols the web server flow's client-secret requirement. Its default isfalse. Setting it totruedoes not remove the generated secret or change the separate secret controls for refresh-token and token-exchange flows. -
isSecretRequiredForRefreshTokendefaults totrueand covers refresh token and hybrid refresh token flows. When it isfalse, clients can omit the secret, but Salesforce still validates a secret if the client sends one. -
isCodeCredentialEnabledenables Authorization Code and Credentials Flow for Headless Identity features.isCodeCredentialPostOnly=truerequires credentials in the initial HTTPS POST body instead of the header. -
isTokenExchangeEnabledenables exchange of external identity-provider tokens for Salesforce tokens.isSecretRequiredForTokenExchangeseparately controls whether the request requiresclient_secret. Salesforce recommends requiring it only for clients with a private backend that can protect the secret. -
isNamedUserJwtEnabledenables JSON Web Token (JWT)-based access tokens. It describes issued access tokens, not the SAML subject or OpenID Connect ID-token configuration.
isIntrospectAllTokens=true authorizes token introspection, or inspection of token status, for all access and refresh tokens in the org. With false, the app can inspect its own tokens. A client that directly registers apps through dynamic client registration can also inspect tokens for its registered apps.
Access sessions, refresh tokens, and ID tokens
Access-session expiration and refresh-token validity are separate controls. Salesforce evaluates oauthPolicy.refreshTokenPolicy when an issued refresh token is used. Changing the policy does not end the user's current access-token session.
-
zeroimmediately invalidates the refresh token, but the already-issued access-token session remains usable. -
infinite, the default, permits indefinite refresh-token use unless the user or administrator revokes it. -
specific_lifetime:number:UNITestablishes a fixed lifetime. -
specific_inactivity:number:UNITestablishes an inactivity interval that resets when the refresh token is exchanged. For example,specific_inactivity:7:DAYSmeasures time since refresh-token use, not simply time since user interaction with the app.
With isRefreshTokenRotationEnabled=true, the client must retain the new refresh token returned by each exchange. Salesforce invalidates the previous token. Reusing that previous token deletes the current refresh token and its associated access tokens, rather than causing only an isolated failed refresh request.
sessionPolicy.sessionTimeout overrides the timeout inherited from the user's profile. If neither the connected app nor the profile specifies a timeout, the org's Session Settings value applies.
When sessionPolicy.sessionLevel applies High Assurance:
-
policyAction=Blockends current connected-app sessions and prevents new sessions. -
policyAction=RaiseSessionLevelrequires multi-factor authentication (MFA) for supported approval-based flows: refresh token, web server, and user-agent flows. API logins through flows without a user approval step, such as JWT bearer, are blocked under High Assurance.
Under oauthConfig.idTokenConfig, idTokenValidity controls only the ID token's lifetime, not the access session or refresh token. Its range is 1-720 minutes, with a default of 2 minutes. Additional idTokenAudience values are returned alongside the relying party's client_id; they do not replace that audience.
The idTokenIncludeAttributes, idTokenIncludeCustomPerms, and idTokenIncludeStandardClaims flags control information emitted in ID tokens. Under assetTokenConfig, assetIncludeAttributes and assetIncludeCustomPerms control inclusion in asset tokens.
IP restrictions
Interpret app-specific ipRanges together with oauthPolicy.ipRelaxation. The ranges are not an independent, universal access rule.
-
ENFORCE, the default, applies org IP restrictions, including profile IP ranges. -
BYPASSallows the app to operate without org IP restrictions. -
ENFORCE_RELAXREFRESHapplies org IP restrictions except when refresh tokens obtain access tokens. -
BYPASS_2FACTORconditionally bypasses org IP restrictions for the web server flow. If the app has allowed IP ranges, requests must come from those ranges. If it has no such ranges, the user must complete identity verification when accessing Salesforce from a new browser or device.
Despite its name, BYPASS_2FACTOR is not a general switch disabling authentication requirements.
Custom execution and Canvas
plugin names an Apex class extending Auth.ConnectedAppPlugin. In contrast, canvasConfig.lifecycleClass names an Apex class implementing Canvas.CanvasLifecycleHandler for Canvas custom parameters. The exposed canvas structure also has a lifecycleClass reference.
pluginExecutionUser requires the ConAppPluginExecuteAsUser setting. If the execution user is not authorized to use the app, the plugin's authorize method is relevant to that authorization.
Canvas accessMethod changes consent behavior:
-
Getrequires the Canvas app to initiate OAuth and prompts the user to authorize access. -
Postposts authentication directly tocanvasUrl. Administrator installation implicitly allows access for users, so users are not prompted for that approval.
canvasUrl is the invoked external application endpoint. Canvas apps can leave startUrl and mobileStartUrl empty. locations controls where the app can appear; None limits it to the Canvas App Previewer. AppLauncher and UserProfile are reserved values, not documented active placement options. options=PersonalEnabled permits end users to install the app as a Canvas personal app.
SAML identity, certificates, and logout
samlConfig configures Salesforce as the identity provider for an external service provider. The service provider supplies acsUrl, its assertion consumer service endpoint, and entityUrl, its entity identifier. samlSubjectType selects the user's SSO identifier; samlNameIdFormat describes the format the provider expects. A custom subject requires samlSubjectCustomAttr.
Certificate representations are not interchangeable:
-
oauthConfig.certificateandsamlConfig.certificatecontain PEM-encoded certificate strings, meaning text-encoded certificate content. -
samlConfig.encryptionCertificatenames a certificate in the org's Certificate and Key Management list. -
oauthConfig.assetTokenConfig.assetSigningCertIdis an ID, not a certificate developer name. Its associated certificate cannot exceed 4 KB.
samlSigningAlgoType selects SHA1 or SHA256 and applies to both SSO and single-logout responses. samlSloUrl supplies the SAML logout endpoint, and samlIdpSLOBindingEnum selects PostBinding or RedirectBinding.
These SAML settings are distinct from OAuth singleLogoutUrl settings. oauthPolicy.singleLogoutUrl must be an absolute HTTPS URL.
Deployment and Retrieval
Metadata API stores components in the connectedApps folder with the .connectedApp suffix. Use ConnectedApp as the type name in package.xml, with component fullName values as members. The type supports the * wildcard in the manifest.
Identity and credential handling
fullName, oauthConfig.consumerKey, and an installed application's record ID serve different purposes. Do not substitute one for another.
consumerKey can be set only during creation and cannot subsequently be edited through this metadata definition. It must be globally unique and contain 8-256 alphanumeric characters, without spaces or special characters. Copying a retrieved definition to another org does not make its existing key available for a separate app registration.
Salesforce ordinarily generates consumerSecret. A custom secret can be supplied only during creation and cannot subsequently be edited through this definition. It has the same length and character constraints as the key. Reusing a secret already assigned to another connected app in the org causes an error.
A retrieval is not a complete credential backup. Metadata API does not return the saved consumerSecret. Its absence from retrieved metadata does not mean that the app has no secret.
Assignment replacement and removal
profileName and permissionSetName require isAdminApproved=true. Supply multiple names on separate lines, without duplicates within either assignment list.
Deployment can replace assignments or remove them using explicitly empty strings, such as <profileName></profileName> or <permissionSetName></permissionSetName>. These empty values have removal semantics; they are not merely omitted descriptive data.
If pluginExecutionUser specifies a user who is not part of the destination org, Salesforce removes that user from the field during deployment.
Callback and scope comparisons
Separate multiple callbackUrl values with line breaks. Programmatic construction uses the \r line-break character. At runtime, Salesforce matches the application's requested callback against one of the registered values.
Retrieval can normalize scope aliases. Deploying Address, Email, Phone, or Profile has the behavior of Basic; deploying OfflineAccess has the behavior of RefreshToken. A retrieve-versus-deploy difference involving these values need not indicate changed authorization intent.
Metadata-only SAML setup
An identity-provider-initiated login URL can identify the app by metadata name: https://<Salesforce_base_URL>/idp/login?apiName=<fullName>.
The alternative form, https://<Salesforce_base_URL>/idp/login?app=<app_id>, uses the service-provider app ID displayed on the connected app's Setup detail page, not fullName.
Relationships
Outgoing references connect the app to custom execution code, encryption certificates, and access assignments. Incoming references are separate configurations pointing to the app, not children contained in its definition. In particular, a token-exchange handler's connectedApp reference is separate from enabling token exchange in the app's OAuth configuration.
References
-
ApexClass:plugin,lifecycleClassundercanvasConfigandcanvas. -
Certificate:encryptionCertificateundersamlConfig. -
PermissionSet:permissionSetName. -
Profile:profileName.
Referenced By
-
AppMenu:name. -
BlacklistedConsumer:consumerName. -
CustomPermission:connectedApp. -
Layout:canvas. -
NotificationTypeConfig:connectedAppName. -
OauthTokenExchangeHandler:connectedApp. -
QuickAction:canvas. -
UserProvisioningConfig:connectedApp.
Documentation Inconsistencies
The SAML subject spellings are inconsistent. The exposed enumeration includes CustomAttribute and PersistentId, while Salesforce's field description uses CustomAttr and PersistentID. Salesforce's declarative example also uses CustomAttribute. These spellings are not established aliases and should not be treated as interchangeable.
The exposed encryptionType enumeration also includes Triple_Des, while the field definition lists AES_128 and AES_256. This discrepancy does not establish that every exposed value is supported in a particular deployment.
Reported Issues
- A connected app's identity can be used across orgs without copying its registration. A 2018 discussion described an app defined in one org authorizing users in other orgs. This is shared application identity, not proof that a particular user or consuming org is authorized. Cross-org application identity discussion.
- Certificate replacement can affect subscribers without a package upgrade. In a 2020 JWT-authentication report, replacing a packaged connected app's certificate in the defining org made the new private key work and the old private key fail in a subscriber org that had not installed the updated package. Subscriber package version did not bound certificate-change impact in that configuration. Subscriber certificate-change report.
-
An AppMenu resolution failure does not necessarily mean the app is absent from Setup. A 2024-2025 DevOps Center discussion reported an
AppSwitcherdeployment failing to resolveChatter_Desktopeven though it appeared in the destination org's Connected Apps UI. No general root cause was established. ExcludingAppSwitcherwas a reported workaround, not a general ConnectedApp repair. AppSwitcher deployment discussion. -
Managed-app retrieval problems can prevent an automated authorization-policy update. In 2019-2020 reports, attempts to read managed connected apps in subscriber production orgs returned no usable definition, blocking an automated
isAdminApprovedupdate even when similar code worked elsewhere. Administrators reported needing to change the permitted-users setting manually. These reports do not override the documented ability of consumers to edit the setting during deployment. Production policy-update discussion and managed-app retrieval report. -
A successful create call did not always apply authorization settings in reported Apex-wrapper usage. A 2019 answer reported that setting
isAdminApproved=trueon a subsequent update worked when setting it during creation did not. Unmanaged permission-set assignments then worked, but modifying an installed managed permission set failed. A 2020 answer reported using a separate permission set andSetupEntityAccessrecords for the association. These are conditional reports, not a required create-then-update sequence. Authorization-setting and assignment reports. -
Copying a registered consumer key can block a scratch-org source push. A 2020 report encountered "The consumer key is already taken" while moving first-generation package metadata into a scratch org for second-generation packaging. The answer described a package reference using the namespace-qualified
developerNameand connected-appversion, rather than recreating the original registration from its full definition. Consumer-key and packaging discussion.
Common Questions
Can I create a new connected app with Metadata API?
New connected-app creation is restricted and requires contacting Salesforce Support. Existing apps remain usable, and Salesforce recommends external client apps for new integrations.
Why is consumerSecret missing from retrieved ConnectedApp metadata?
Metadata API does not return the saved secret. A missing retrieved value does not mean that the app has no secret, and the retrieved definition is not a complete credential backup.
Does setting refreshTokenPolicy to zero immediately log users out?
No. It immediately invalidates the refresh token, but does not end the already-issued access-token session. Session timeout is a separate control.
How do I preauthorize users and remove connected-app assignments?
Set oauthConfig.isAdminApproved=true and supply authorized profileName or permissionSetName values. Explicitly empty assignment strings have removal semantics during deployment. Effective access also depends on the user's actual assignments and session policies.
Can changing a connected app certificate affect orgs that have not upgraded the package?
Yes, that was reported for a packaged JWT-authentication configuration in 2020. Replacing the certificate in the defining org changed which private key worked in a subscriber org without installing the updated package.