Sub topic 13
Choosing and securing the run-as user
This chapter assumes you can configure a connected app, you know how the client credentials flow works, and you have admin access to a Salesforce org. The client credentials flow has no login step, so the connected app must say which user the token represents. That user is the run-as user.
What the run-as user controls
An access token from the client credentials flow carries the identity and permissions of the run-as user. Every API call is checked against that user's profile, permission sets, field-level security, and sharing rules. Records the integration creates or edits show this user as their creator or last modifier.
You set the user in the connected app: Manage → Edit Policies → Client Credentials Flow → Run As. Only one user can be selected per connected app.
Choosing the user
Create a dedicated user for each integration. Do not reuse an administrator or a person's account. A shared or personal account causes three problems:
- The integration inherits far more access than it needs.
- Audit trails mix human and machine activity.
- Deactivating a person when they leave also breaks the integration.
Use these settings for the dedicated user:
| Setting | Recommendation |
|---|---|
| License | Salesforce Integration user license, if your org has it and it covers the use case |
| Profile | A minimal profile, such as Minimum Access - API Only Integrations |
| Permissions | A permission set that grants only the objects and fields the integration uses |
| Username | A clear name such as `[email protected]` |
| A monitored shared mailbox, not a personal address |
Securing the user
The token is only as safe as the user behind it, so limit what that user can do:
- Grant object and field access through a permission set, and review it when the integration changes.
- Leave out "Modify All Data" and "View All Data" unless the integration truly needs them.
- Keep the user out of interactive use. The integration user license and the API Only profile setting block UI logins.
- Monitor the user with login history and event monitoring.
Changing and deactivating the user
If you deactivate the run-as user, token requests fail. If you change the run-as user on the connected app, new tokens use the new user's permissions. Tokens already issued remain valid until they expire or are revoked. Plan any change for a quiet window and test it in a sandbox first.
Exercise
A team sets the run-as user of a client credentials connected app to the system administrator who set it up. Name two risks and one fix.
Show answer
The integration gets administrator-level access, which is far more than it needs. If that administrator is deactivated, the integration stops working. Audit records also blend the person's actions with the integration's. The fix is to create a dedicated integration user with a minimal profile and a permission set limited to the required objects and fields, then set that user as the run-as user.