I have a trouble between integration with SalesForce and our's service.

We are using oauth2 authorization and SalesForce REST API.

Our clients authorize successfully for the first time and get the access and refresh tokens. But the access token is expired. So the error is always 'Session expired or invalid'.

When we try to refresh it via refresh token request it returns the same access token. And so the error is the same.

Refresh token has unlimited lifetime in the salesforce app settings.

Are we doing something wrong? or our clients has some bad settings?

Thank you

  • Can you post the code you're using to do the refresh, and the API call? Sounds like maybe an encoding issue.
    – metadaddy
    Commented Oct 28, 2015 at 3:00
  • 1
    The problem was in our app with wrong instance url. Commented Nov 2, 2015 at 10:11
  • Glad you got it working! Could you post that as the answer, so it's more obvious for future devs that might have done the same? Thanks!
    – metadaddy
    Commented Nov 2, 2015 at 21:28

2 Answers 2


It probably has to do with settings. The session timeout for an access token can be configured in Salesforce from Setup by entering Session Settings in the Quick Find box, then selecting Session Settings.


Make sure you are using the session token with the correct instance URL.

You'll get a Session expired or invalid error if you try to use a production org's session against one of your sandbox instances, for example.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .