Salesforce Sandbox OAuth error: [invalid_grant] expired access/refresh token. How to send refresh token or keep session alive

Hello,

 

I am receiving this error continually when using OAuth to connect to my Salesforce Sales Cloud Sandbox:

 

 [invalid_grant] expired access/refresh token

 

Not sure what is causing this but I am trying to find a way to either:

 

  1. Keep the OAuth connection alive indefinitely
  2. Refresh the OAuth connection when this error occurs
    1. There is an "Advanced Connection Options" checkbox in the the "Manage OAuth" object that links to this document (https://matillion-docs.s3.eu-west-1.amazonaws.com/datamodels/Salesforce.html#Connection) but still struggling to find what exact values I need to input:
      1. OAuthTokenTimestamp
      2. OAuthExpiresIn

 

Thank you!

UPDATE: Working with my Salesforce Admin and there was a configuration "Force Log-out" when the token expires in the sandbox environment. We have disabled that configuration and upon revalidation of the "Salesforce Output" component can connect again.

 

Would still like to use a better option from my above points if possible for more secure keep-alive connection methods.

UPDATE: Matillion support pointed me to this URL (https://support.matillion.com/s/article/ErrorinvalidgrantExpiredAccessRefreshTokeninSalesforceOAuth) which i will try next once this issue occurs again:

 

  1. Setup a new Salesforce OAuth Profile
  2. In the "Configure OAuth" dialog, set "Use Sandbox" = Yes
  3. Configure a Salesforce Query component to use the new Salesforce OAuth Profile you created above.
  4. In "Connection Options" add the following parameter. The parameter is not shown in the drop-down, but you can manually type it in.
  • Parameter: usesandbox
    • Value: true

 

Hope this may help others than may run into this issue

UPDATE: Using the above connection option fixed this issue. Ensure the case sensitivity is all lower case!