I'm facing a problem with one of my Sandboxes. Today I noticed that Access Token received from Connected App doesn't work (Session expired or invalid - INVALID_SESSION_ID). It's weird because everything was working fine on Friday. I created another app, but it still has the same problem. I also created Connected App on my private Developer Org and I still can't retrieve any data. I'm suspecting, that it can be general Salesforce problem, do you have the same problem with your connected apps?

Thanks in advance.


Access Tokens have a finite lifespan. If your external application needs to maintain persistent access to Salesforce, you need to implement one of the several OAuth flows that provide a refresh token, such as the User-Agent or Web Server, or the JWT flow, which doesn't provide a refresh token but allows renewed authentication at any time via certificate.

Once your application receives and securely stores a refresh token, it can make further calls to Salesforce to generate fresh access tokens whenever the one it's holding should expire. From the documentation of the Refresh Token flow:

After the consumer has been authorized for access, it can use a refresh token to get a new access token (session ID). This process happens only after the consumer has received a refresh token using either the web server or user-agent flow. It’s up to the consumer to determine when an access token is no longer valid and when to apply for a new one. Bearer flows can be used only after the consumer has received a refresh token.

  • Also worth mentioning that the lifespan of the token is determined by the same timeout policy set for your entire org...unless you specifically override that timeout in the connected app itself. Also, making a request using a (currently valid) token will reset its timeout.
    – Derek F
    Jul 29 '19 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.