Índice do artigofaltam 7 min de leitura
The integration is configured, the OAuth flow was implemented according to the documentation, and the token only comes out when an authorized person opens the browser and logs in. A server doesn't do that at three in the morning.
This is one of the most frustrating moments in a CRM integration project, because everything seems right. The credentials are correct, the endpoint responds, the documentation was followed. And still, the integration doesn't run on its own.
The diagnosis usually takes a while because the team looks for the error in the wrong place. There is no error. The chosen authentication flow was simply designed for something else.
Article summary
- OAuth is not a single flow. It's a family, and several members of it assume a human in front of a consent screen.
- For server-to-server integration, Salesforce documents the JWT bearer flow as the path for automated environments that don't support interactive browser login.
- It requires a digital certificate, a private key, an OAuth app with the certificate registered and that app's consumer key. For a new integration, that app is an External Client App, because since Spring '26 creating a new connected app is blocked by default.
- There's one exception that breaks the design: an org with stepped up authentication asks for identity verification and blocks the non-interactive flow.
The symptom: everything right and no token
In a portal project for a medical equipment manufacturer, the team configured the OAuth2 flow exactly according to the material received from the other side. The connection responded. But to get the access token, an authorized user from the org had to log in on the Salesforce screen.
For an integration that needs to sync data continuously, this is not an inconvenience: it's a structural blocker. Nobody is going to renew a token by hand every day, and an integration that depends on someone being awake is not an integration.
-
The OAuth flow is implemented according to the documentation received
Correct credentials, endpoint responding, no errors in the console.
-
The token is only issued after a human logs in on screen
The team spends days looking for a configuration defect, because nothing is technically wrong.
-
The question changes from "where is the error" to "which flow works for a server"
The problem stops being one of implementation and becomes one of flow choice.
-
A certificate-based flow, with no browser in the path
The dependency moves from a person being present to a key the company controls.
What this unlocks, in project terms: recognizing the symptom early saves the most expensive part, which is discovering it after the delivery date has been communicated to the client.
OAuth is not a flow, it's a family of flows
The confusion starts here. "Use OAuth" describes as little as "use HTTP". What matters is which flow, because each one answers a different question about who is authorizing what.
| Situation | Who authorizes | Works for a server on its own? |
|---|---|---|
| User connects their own account to an app | The person, on the consent screen | No. It assumes someone is present |
| Application acts on behalf of whoever is logged in | The person, in each session | No. The context belongs to the session |
| System talks to system, with nobody in front | A private key the company keeps | Yes. This is the JWT bearer flow case |
The bottom row is the one that solves enterprise integration. The ones above aren't wrong: they answer another question, and they're the right choice when the product really connects each user's individual account.
The JWT bearer flow exists exactly for this
Salesforce's documentation is explicit about the purpose: the flow was designed for automated integration environments, those that, in the documentation's own words, don't support the human interactivity of logging in through a browser.
The mechanism trades a person's presence for cryptographic proof. Instead of someone consenting on screen, the system presents an assertion signed with a private key only it has, and the org validates that signature against the previously registered public key. Trust no longer depends on a human event; it depends on a secret the company controls and can rotate.
What needs to exist before writing code
Four pieces, and none of them is integration code. It's worth gathering all of them before estimating a timeline, because two depend on whoever administers the Salesforce org, not on the development team.
- A digital certificate, which can be self-signed, generated with a standard cryptography tool.
- The matching private key, kept in a secrets vault and never in a repository.
- An External Client App configured in the org (or a connected app that already exists), with the JWT bearer flow enabled and the certificate registered in it.
- That app's consumer key, which identifies the application when requesting the token.
Item 3 changed in 2026. Since Spring '26, Salesforce blocks the creation of new connected apps by default, through the interface and the API, except for package installation. Unblocking requires a ticket with Salesforce support, a workaround the company itself warns won't be available in future releases, and Salesforce's developer guide justifies the block by saying connected apps are being phased out. The path for a new integration is the External Client App, which Salesforce calls the next generation of connected apps and which also supports the JWT bearer flow. Connected apps that already exist keep working, so an older integration doesn't stop because of this.
In the External Client App, the JWT bearer flow isn't switched on. You need to enable it in the app's flows section, upload the certificate file and, in the policies, mark that only admin-approved users are pre-authorized, specifying the integration user's profile or permission set. Without this pre-authorization, the token won't come out even with the correct certificate and consumer key.
Items 3 and 4 depend on administrative access to the org, and so does the user's pre-authorization. At a large client, that usually means an internal ticket with its own queue, and that's precisely the dependency that needs to go into the schedule with a name and a date.
The exception that breaks the design
There's one case in which the whole plan above doesn't hold, and it needs to be checked before, not after.
When the org uses elevated-level authentication, known as stepped up authentication, Salesforce starts requesting identity verification, which prevents authentication without human interaction. If the client's security policy requires it, the design needs to change, and the conversation stops being technical and becomes one of governance with the information security team.
Sandbox and production are not the same environment
It seems obvious and it brings integrations down at cutover. The sandbox login URL is different from production's, and a token requested with the wrong URL comes back with an invalid audience error. Credentials also need to be checked in each environment: the OAuth app (External Client App or connected app), the certificate registered in it, the consumer key in use and the integration user's pre-authorization.
The pattern that avoids the surprise is treating the environment as configuration from day one, never as a hard-coded value, and doing at least one full run against production before the cutover date, even if read-only.
Who is the integration user
A small decision that prevents a big problem: the integration shouldn't run with a person's account.
An employee account is subject to password changes by policy, permission changes when the person changes departments and deactivation when they leave the company. Any of these events brings the integration down, always at a moment nobody is expecting, and the diagnosis takes time because the symptom doesn't point to the cause.
The way to go is a user dedicated to the integration, with the minimum set of permissions needed and a named owner. This also improves auditing: the log makes clear what was done by the system and what was done by a person.
When the CRM decides what the user sees
A product warning is worth adding, because this is the second trap in this kind of project. It's common for a person's status in the CRM to start determining what they see in the portal or app.
The rule seems simple to describe and is full of edge cases. What happens to someone who just signed up and hasn't been classified yet? What happens when the status changes in the CRM while the person is logged in? And when sync fails, does the behavior grant or block access?
These three questions need a written answer in the data contract, before implementation. Without them, the default behavior ends up being decided by accident, and it's usually the most restrictive one, which shows up as legitimate users without access to the content they should see.
Frequently asked questions
Because the flow you chose was designed to authorize a human user. Flows that open a consent screen assume someone is present to approve. A server integration needs a flow that doesn't depend on that interaction.
The JWT bearer flow. Salesforce's documentation describes it as intended for automated environments that don't support the human interactivity of logging in through a browser, which is exactly the case of a server-to-server integration.
A digital certificate, which can be self-signed, the matching private key, an OAuth app in the org with the certificate registered and the JWT bearer flow enabled, and that app's consumer key. For a new integration, that app is an External Client App: since Spring '26 Salesforce blocks the creation of new connected apps by default. Connected apps that already exist keep working.
Yes. When the org uses stepped up authentication, Salesforce requests identity verification, which prevents authentication without interaction. This needs to be confirmed with whoever administers the org before the design is closed.
No. The safe practice is a user dedicated to the integration, with minimal permissions, that doesn't leave the company, doesn't change its password because of HR policy and doesn't disappear when someone changes departments.
No. The sandbox login URL is different from production's, and a token requested with the wrong URL comes back with an invalid audience error. The OAuth app, the certificate, the consumer key and the integration user's pre-authorization need to be checked in each environment.
Sources and method
The statements about the JWT bearer flow come from Salesforce's official developer documentation, checked on August 31, 2026, including the flow's stated purpose for automated environments, the prerequisites of certificate, private key, OAuth app and consumer key, and the caveat about orgs with stepped up authentication. On November 11, 2026 the text was reviewed against Salesforce's knowledge article on blocking connected app creation in Spring '26 and against the Salesforce DX Developer Guide (Winter '27 version, updated on September 25, 2026), which describes configuring the JWT bearer flow in an External Client App, user pre-authorization and the audience error between sandbox and production.
The case cited comes from a project carried out by the X-Apps team in 2025 and has been anonymized, since the relationship between this client and the system is not public. Salesforce prices, call limits and service levels were not researched and therefore don't appear in the text.





