Sub topic 16
Migrating from connected apps to ECAs
This chapter assumes you know how connected apps and external client apps (ECAs) differ, how settings and policies are split in an ECA, and how the JWT bearer, client credentials and authorization code flows work. It covers how to move a working integration from a connected app to an ECA without an outage.
Why and when to migrate
Salesforce now steers new integrations toward ECAs. In recent releases, creating new connected apps is turned off by default, and admins can re-enable it with an org setting. Existing connected apps keep working, so migration is not an emergency. Plan it when you:
- need packaging and distribution that separates developer settings from admin policies
- want stricter defaults, such as flows enabled one by one
- manage apps as source-controlled metadata
- are rebuilding an integration anyway
Check the current release notes for your org before you start. Salesforce has been adding migration tooling, and what it can do depends on your release.
What maps to what
| Connected app setting | ECA location | Notes |
|---|---|---|
| Callback URL, scopes, enabled flows | OAuth settings (developer side) | Enable each flow explicitly. |
| Certificate for JWT bearer | OAuth settings | Upload the same certificate if the key pair is staying. |
| Permitted users, IP relaxation | Policies (admin side) | Set per org, not shipped with a package. |
| Refresh token policy, session timeout | Policies | Review them, because defaults can differ. |
| Run-as user for client credentials | Policies | Set it again in the new app. |
| Profile and permission set access | Policies | Reassign access in the new app. |
| SAML single sign-on | Not a one-click copy | Check current support before planning. |
A migration plan
The safest approach runs the old and new apps side by side, moves clients one at a time, and retires the old app last.
1. Inventory
For each connected app, record the following:
- the consumer key and which systems use it
- the enabled flows
- the scopes and callback URLs
- the policies: permitted users, IP relaxation, refresh token policy, run-as user
- the assigned profiles and permission sets
The OAuth usage and connected apps pages in Setup show which apps are active. Low-use apps are good candidates to retire instead of migrate.
2. Create the ECA
Create the ECA in External Client App Manager. Copy only what the integration needs.
- Enable only the flows the client uses.
- Keep PKCE on for the authorization code flow.
- Request the minimum scopes. Do not copy a broad scope list just because the old app had one.
Creating an ECA by hand generates a new consumer key and secret. Every client has to change its configuration to use them. If you use a Salesforce migration feature that preserves the key, confirm that behavior in your release before relying on it.
3. Set policies and access
Policies do not carry over automatically in a hand-built ECA. Set permitted users, the IP policy and the refresh token policy again, then assign permission sets. If you use "admin approved users are pre-authorized", users who lack the permission set get an access error when they authorize.
4. Test each flow
Test in a sandbox first. For a client credentials integration, confirm that the run-as user is set and can reach the objects the integration needs:
TOKEN_JSON=$(curl -s -X POST https://MyDomain.my.salesforce.com/services/oauth2/token \
-d grant_type=client_credentials \
-d client_id="$NEW_CONSUMER_KEY" \
-d client_secret="$NEW_CONSUMER_SECRET")
ACCESS_TOKEN=$(printf '%s' "$TOKEN_JSON" | python3 -c 'import json,sys; print(json.load(sys.stdin)["access_token"])')
curl https://MyDomain.my.salesforce.com/services/data/ \
-H "Authorization: Bearer $ACCESS_TOKEN"A list of API versions means the token works. A token that works here can still fail on real objects, so also run one request that the integration actually makes.
For a JWT bearer integration, change two things: the iss claim becomes the new consumer key, and the key pair must match the certificate uploaded to the ECA.
{
"iss": "<new consumer key>",
"sub": "[email protected]",
"aud": "https://login.salesforce.com",
"exp": 1767225600
}In CI, swap the client ID in the CLI login:
sf org login jwt \
--client-id "$NEW_CONSUMER_KEY" \
--jwt-key-file server.key \
--username [email protected] \
--instance-url https://login.salesforce.com \
--alias ci-org5. Cut over
Switch one client at a time, starting with the least critical. Store the new key and secret in your secrets manager, not in the repository.
Things that break
- Existing tokens. Tokens and refresh tokens issued by the connected app are tied to it. Users of an authorization code integration have to authorize again against the new app.
- Hard-coded consumer keys. Mobile apps, scripts and middleware often embed the key. Search your repositories and integration platforms before you cut over.
- Run-as user differences. If the new app uses a different user than the old one, API permissions change silently.
- Callback URL mismatches. The
redirect_urimust exactly match a registered URL, including the trailing slash. - Flows left disabled. In an ECA, a flow you did not enable is rejected, even if the old app allowed it.
- Packaged apps. If you ship a connected app in a managed package, plan a separate release path. Customers have to install and configure the ECA version.
Source-driven migration
ECAs are metadata. Retrieve them with the Salesforce CLI and keep them in version control. This keeps settings the same across sandboxes and production. Policies are org-specific, so deploy them separately and review them for each environment. Secrets are never stored in the metadata.
Retiring the connected app
- Watch login history and OAuth usage for the old app until no traffic remains.
- Set the old app's permitted users to admin approved users only, then remove the access assignments. Clients still using it fail visibly, and you can reverse the change.
- Wait through at least one full cycle of scheduled jobs.
- Delete the connected app.
Exercise
A nightly integration uses the JWT bearer flow against a connected app. You create an ECA, upload the same certificate, and update the client's consumer key. The token request fails. Name three things to check.
Show answer
Check that the JWT bearer flow is enabled in the ECA's OAuth settings. Check that the iss claim holds the new consumer key and that the signing key matches the uploaded certificate. Check that the user in sub has access through a permission set assigned to the ECA, and that the policies allow that user. Also confirm the aud URL matches the login or My Domain URL.
Exercise
Why should you block the old connected app before deleting it?
Show answer
Blocking is reversible and exposes any client you missed, because that client fails visibly. Deleting cannot be undone and removes the app's records. Blocking gives you a rollback while you confirm that nothing depends on the app.