Sub topic 2
Granting Access with Permission Sets
Assume you know Salesforce users, profiles, objects, fields, SOQL, and OAuth 2.0. The effective access of an integration user comes from several layers: its profile, permission sets, field-level security, and sharing rules.
Granting Access with Permission Sets
Use a minimal profile as the base, then add integration-specific access with a permission set. Permission sets add permissions; they do not remove permissions already granted by the profile.
Start with the integration's requirements:
- Which objects must it read or change?
- Which fields must it read or change?
- Does it need the API Enabled system permission?
- Does it need access to every record or only records shared with it?
A permission set should contain only those answers.
<?xml version="1.0" encoding="UTF-8"?>
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
<label>Integration Account Read</label>
<userPermissions>
<enabled>true</enabled>
<name>ApiEnabled</name>
</userPermissions>
<objectPermissions>
<allowCreate>false</allowCreate>
<allowDelete>false</allowDelete>
<allowEdit>false</allowEdit>
<allowRead>true</allowRead>
<modifyAllRecords>false</modifyAllRecords>
<object>Account</object>
<viewAllRecords>false</viewAllRecords>
</objectPermissions>
</PermissionSet>Assign the permission set only to the dedicated integration user. Use permission set groups when several related permission sets form a reusable job role. Avoid assigning broad administrator permissions for convenience.
Object and Field-Level Permissions
Object permissions control actions such as read, create, edit, and delete. Field-level security controls whether the user can read or edit a particular field. Both layers apply to API requests.
For example, read access to Account does not automatically make every Account field readable. The user also needs field-level read permission for fields such as Industry. Do not grant View All or Modify All unless the integration truly requires access beyond sharing rules.
Sharing Model and Record Visibility
Object permission answers “may this user read Accounts?” Sharing answers “which Account records may this user read?” Organization-wide defaults, role hierarchy, sharing rules, teams, and manual sharing can limit record access.
Authenticating the Integration with OAuth
Configure a connected app or external client app for the required OAuth flow. Pre-authorize the integration user when supported, then issue tokens for that user. OAuth proves identity; it does not grant Salesforce permissions. The token inherits the user's effective access.
Verify both allowed and denied operations while logged in as the integration user.
sf data query \
--target-org integration-sandbox \
--query "SELECT Id, Name, Industry FROM Account LIMIT 5"Exercise
Why can an integration user authenticate successfully but still receive an authorization error for an API query?
Show answer
OAuth identifies the user, but the user's profile, permission sets, field security, or sharing rules may deny the requested access.