Loading

Preventing Connector Authentication Token Expiration Failures

Publiceringsdatum: Aug 7, 2026
Beskrivning

Problem Statement

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 closed
  • OAuthException: Error code invalid_grant: ID Token issued at [timestamp] is stale

These errors occur after successful initial authentication, indicating token refresh logic is not executing correctly.

Root Causes

  1. Token lifetime shorter than connector refresh interval - Tokens expire before connector attempts refresh
  2. MuleSoft IdP limitations with external identity providers - Workload Identity Federation with Google/Azure may not support MuleSoft as IdP
  3. Object Store persistence blocking token refresh - Persistent Object Store V2 may cache stale tokens
  4. Silent token refresh failures - Connector continues using expired token without error until API call fails
Lösning

Step 1: Configure Explicit Token Refresh Parameters

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>

Step 3: Avoid Persistent Object Store for OAuth Tokens

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

  1. Always configure <reconnect-forever/> at both connection and operation levels

  2. Use service account credentials instead of MuleSoft IdP for Google/Azure

  3. Set token refresh buffer to at least 5 minutes before expiration (300 seconds)

  4. Avoid persistent Object Store for OAuth token caching

  5. Enable debug logging during initial deployment to verify token refresh

  6. Monitor logs for UNAUTHENTICATED or INVALID_SESSION_ID errors

  7. Test token expiration scenarios in non-prod with short token lifetimes

 








    Knowledge-artikelnummer

    005390720

     
    Laddar
    Salesforce Help | Article