Sub topic 2
What a connected app is and what it does
This chapter assumes you can work in Setup, know what profiles and permission sets are, and have sent an HTTP request with curl. It does not assume you know the OAuth settings fields. Those come in the next chapter.
The problem a connected app solves
An outside program, such as a mobile app, a CI job, or a middleware service, needs to call Salesforce APIs. Salesforce must know which program is calling and what it may do. It also needs a way to shut that program out without changing any user's password.
A connected app is the Salesforce record that gives an external application an identity in your org. It holds the app's registration, its allowed access, and its rules for how users and tokens are handled.
What a connected app holds
A connected app bundles four things:
- An identity. OAuth issues the app a consumer key (its public ID) and a consumer secret.
- OAuth settings. These are the callback URL, the scopes the app may request, and which flows it may use.
- Policies. These decide who may use the app, from which IP addresses, and how long refresh tokens last.
- Optional SAML settings. These let the app act as a single sign-on target.
Every OAuth access token Salesforce issues is tied to one connected app and one user. That link is what lets you review and revoke access per app.
Where it sits in a request
The token carries two limits. The connected app's scopes cap what the token can do. The user's profile and permission sets cap what data that user can reach. The token never grants more than either limit allows.
Seeing it in your org
In Setup, search for App Manager. Connected apps appear in the list, and you can create one with New Connected App. After a user authorizes an app, it shows in that user's connected apps and OAuth usage list. An admin can review and revoke it from there.
Checking that a token works
Once an app has an access token, you can confirm it with a simple call to the REST API versions resource:
curl https://MyDomain.my.salesforce.com/services/data/ \
-H "Authorization: Bearer $ACCESS_TOKEN"A list of API versions means the token is valid. A 401 response means it is expired, revoked, or sent to the wrong org.
Common mistakes
- Treating the connected app as the security boundary. It sets scopes and policies, but a user's permissions still decide what data is returned.
- Sharing one connected app across unrelated integrations. A shared app means a shared consumer key, so you can't revoke one integration without breaking the others.
- Leaving policies at their defaults. Settings such as permitted users and IP relaxation affect real behavior, and a later chapter covers them.
Exercise
An integration's access token has the api scope, but the user it runs as lacks read access to the Contact object. What happens when the app queries Contacts, and why?
Show answer
The query fails or returns no Contact data. The api scope only allows the token to use the API. The user's profile and permission sets still decide which objects and records the token can read, so the token cannot exceed the user's access.