Loading

"Access token expired / refresh failed" failures in MuleSoft Composer - Knowledge Article

Data pubblicazione: Sep 25, 2026
Descrizione

Scope: This article covers Composer's Salesforce connector (Composer connecting to a Salesforce org). The new rotation rule below is enforced on Salesforce since Aug 24, 2026. Other connectors may be impacted in a similar fashion - so general principles explained here are applicable widely, however this article is about the Salesforce connector.

Who this is for:

You run Mulesoft Composer flows that use the Salesforce connector. Sometimes flows fail with a token error even though the connection worked before. This article explains why, and best practices for higher stability.

Background: access token vs refresh token
 
When Composer connects to Salesforce with OAuth, it gets two tokens:
- Access token: The short-lived key. It lets Composer call Salesforce. It expires fast, often in an hour.
- Refresh token: The long-lived key. When the access token expires, Composer sends the refresh token to get a fresh access token. No human login needed.

Normal cycle:
1. Access token expires.
2. Composer sends the refresh token to Salesforce.
3 Salesforce returns a new access token.
4. Flow keeps running.

Note: A Composer connection stores one token set (access token and refresh token). Every flow that uses the same connection shares the same access token and refresh token.

Enhanced security control
There is a new Salesforce security rule called Refresh Token Rotation (RTR). When Composer uses the refresh token to get a new access token, the old refresh token is thrown away and a new one takes its place. Only the newest refresh token works. Any older copy is invalid.

RTR restricts it even further: if something tries to reuse an invalid refresh token, Salesforce treats it as a theft attempt and revokes everything for that connection – the current refresh token and all access tokens. After that, the connection cannot refresh at all and needs a fresh login (reconnect).

This is safer, but it changes how a connection behaves when more than one flow uses it.

Scenario 1: 2+ flows share one connection and collide

All flows on a connection share the same tokens, so two flows can try to refresh at the same time.
Before RTR this was mostly harmless (however, still could lead to race conditions and errors in one of the flows: if one flow won the refresh, the other flow's refresh failed for that single run, and the next run picked up the new token – this is confusing, yet not fatal)

With RTR it becomes an issue: the “losing” flow is now holding a refresh token that is already dead, and reusing a dead token is treated as a theft attempt:
  1. Access token expires.
  2. Flow A sees it is stale and starts a refresh.
  3. Flow B sees it is stale and also starts a refresh, using the same refresh token.
  4. Flow A finishes first. It gets a new access token and a new refresh token. The old refresh token is now dead.
  5. Flow B still holds the old refresh token and tries to use it.
  6. Reusing a dead refresh token counts as a theft attempt, so Salesforce revokes everything for that connection.
  7. Every flow on that connection now fails until you reconnect.

The more often a connection runs, the more likely this collision. Frequently Scheduled and Triggered flows that fire often are the worst case.

Update: as of Sep 22, 2026 Composer reconnection process was upgraded to mitigate this issue and it is now safe to use the same Salesforce connection across multiple flows.



Scenario 2: Too many approvals for the same connected app
ℹ️This is existing limitation, however it becomes more critical with RTR in place.

Salesforce limits active connections per app, per user. The limit is 5. Each time you authorize a connection you add an approval, and for OAuth 2.0 each refresh token counts as one. If a user creates a 6th connection (approval), the oldest approval is revoked, which invalidates whatever connection was using it.

See Manage OAuth-enabled connected apps access to your data - official Salesforce article on this topic.

if a user creates a new connection for every flow, they can push older ones past the limit and inadvertently invalidate them. Flows on those invalid connections then fail with the same kind of token error or similar like "Session expired or invalid" (with error code "INVALID_SESSION_ID").

Note: All connectors external systems (not only Salesforce) enforce their own limits set by that provider - please refer to particular system documentation to learn more.

What the error looks like
In the flow run you will see something like:

Error Message: AccessToken expired at operation '...'.
Refresh token workflow was attempted but failed.

Under the hood the OAuth response is:

{"error":"invalid_grant","error_description":"expired access/refresh token"}

There are multiple scenarios (including IP range changes, disabling user, changing session configuration etc) that can lead to the exactly same error, so the message alone will not tell you which issue was encountered.


Risoluzione

The issue described in the scenario 1 is resolved now (as of Sep 22, 2026) at application connection level and it is OK to use the same connection across multiple flows - however scenario 2 is still platform level limitation - please keep this in mind. 


Best practices:
 

1 . Keep the number of connections to one Salesforce org small. Stay under 5 approvals per user for a given app.
   Note: other external systems may have different limits - consult respective documentation for details.
2. Do not create a new connection for every flow. That burns through the limit.
3. If a connection fails, open it in flow design mode and reconnect. That gets fresh tokens. If reconnecting fixes it and then a different flow starts failing, you are hitting one of the described scenarios.

Numero articolo Knowledge

005393404

 
Caricamento
Salesforce Help | Article