Applications using connectors like Salesforce, Google Pub/Sub, Azure Service Bus, or OAuth-based APIs experience intermittent authentication failures with errors such as:
error=invalid_client_id&error_description=client identifier invalid (Salesforce)UNAUTHENTICATED: Failed computing credential metadata (Google Pub/Sub)INVALID_SESSION_ID: This message consumer is closedOAuthException: Error code invalid_grant: ID Token issued at [timestamp] is staleThese errors occur after successful initial authentication, indicating token refresh logic is not executing correctly.
For Salesforce Connector:
<salesforce:sfdc-config name="Salesforce_JWT_Config">
<salesforce:oauth-jwt-connection
consumerKey="${secure::salesforce.consumerKey}"
keyStorePath="keystore.jks"
storePassword="${secure::salesforce.storePassword}"
principal="${salesforce.username}"
keyAlias="${salesforce.keyAlias}"
<reconnection>
<reconnect-forever frequency="5000"/>
</reconnection>/>
</salesforce:sfdc-config>
Step 2: Use Service Account Credentials (Not MuleSoft IdP)
Known Limitation: MuleSoft IdP is NOT supported by Google Cloud for Workload Identity Federation. Enterprise security teams often reject MuleSoft as an external IdP.
Recommended Solution: Use Google Service Account JSON directly:
<google-pubsub:config name="Google_Pubsub_Config">
<google-pubsub:service-account-connection projectId="${gcp.projectId}">
<google-pubsub:service-account-key-file path="src/main/resources/gcp-service-account.json"/>
</google-pubsub:service-account-connection>
</google-pubsub:config>
Problem: Object Store V2 with persistent="true" may cache expired tokens across application restarts.
Solution: Use in-memory Object Store or configure shorter TTLs.Best Practices
Best Practices
Always configure <reconnect-forever/> at both connection and operation levels
Use service account credentials instead of MuleSoft IdP for Google/Azure
Set token refresh buffer to at least 5 minutes before expiration (300 seconds)
Avoid persistent Object Store for OAuth token caching
Enable debug logging during initial deployment to verify token refresh
Monitor logs for UNAUTHENTICATED or INVALID_SESSION_ID errors
Test token expiration scenarios in non-prod with short token lifetimes
005390720

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.