Sub topic 16
Migrating from Connected Apps to ECAs
This chapter assumes you know how connected apps, OAuth flows, and policies work, and that you can use curl and Setup. It covers how to plan a move to external client apps (ECAs), then the security practices to apply once you're there.
Migrating from connected apps to ECAs
Migration swaps the app definition and keeps the integration running. Clients should keep working with no code change, so plan around what the client sees: the consumer key, the callback URL, the flow, and the scopes.
Plan the move
- Inventory your connected apps. Note the flow each one uses, its scopes, and its policies (permitted users, IP relaxation, refresh token policy).
- Separate the settings from the policies. In an ECA, developer-owned settings (callback URL, scopes, flow enablement) and admin-owned policies are stored separately, so decide who owns each.
- Check which apps use features you still need, such as SAML single sign-on. Confirm that the ECA supports them before you move.
- Migrate a sandbox copy first. Salesforce provides a migration option in Setup for OAuth-enabled connected apps. Confirm in the release notes that your app type is eligible.
- Test each flow against the new app, then migrate production.
Verify after migration
Request a token with the same flow your client already uses, then call the API with it:
curl https://MyDomain.my.salesforce.com/services/data/ \
-H "Authorization: Bearer $ACCESS_TOKEN"A JSON list of API versions means the token works. A 401 usually means a policy did not carry over, so recheck permitted users and the permission sets assigned to the app.
Security best practices
- Prefer the narrowest flow. Use authorization code with PKCE for user-facing apps, JWT bearer or client credentials for servers. Avoid flows that handle passwords.
- Request minimal scopes. Grant
apiinstead offull. Addrefresh_tokenonly when the client needs long-lived access. - Restrict who can use the app. Set permitted users to "Admin approved users are pre-authorized" and assign permission sets rather than whole profiles.
- Use a dedicated run-as user. For JWT bearer and client credentials, create an integration user with a minimal permission set. Never use a personal admin account.
- Protect secrets. Keep the consumer secret and private key in a vault or CI secret store, never in source control. Rotate them on a schedule and after any exposure.
- Keep IP relaxation strict. Enforce IP restrictions for server integrations and allow relaxation only where it is needed.
- Use short-lived JWTs. Set
expa few minutes ahead and use the correctaudfor production, My Domain, or sandbox. - Review usage. Check login history and active OAuth sessions regularly, and revoke tokens you do not recognize.
Exercise
After migrating a server integration that uses the JWT bearer flow, the token request fails. Name two settings you would check first.
Show answer
Check that the app's policies pre-authorize the integration user (admin approved users, with a permission set assigned to that user). Check that the certificate uploaded to the new app matches the private key that signs the JWT. Also check that iss is the consumer key and aud is the right login URL.