My company is using the OAuth "Refresh Token" flow, and can get an accessToken and refreshToken fine using this flow.

The problem I'm having is that the responses we receive from Salesforce don't have an exp field in them, so we don't know how long an accessToken lives for.

   "scope":"id api refresh_token"

Is there a way to find out how long the accessToken lives for?

We can change our request of course to include different scopes if need be.

Note that I've noticed that there's a beta endpoint that lets you request this information, but it feels to me like something that should be returned with the accessToken and refreshToken.

  • 1
    I think this answer is still applicable: salesforce.stackexchange.com/questions/73512/… – David Cheng Dec 19 '18 at 15:59
  • One way could be to calculate using issued_at. A token will live for the duration specified in the session settings. So as long as you have the issued_at available and you know the session settings duration, you can calculate the token's lifespan. – Jayant Das Dec 19 '18 at 16:07
  • 2
    Access tokens automatically update their expiration if at least half the time has passed since issue and it is used in any API call. Also, a user or admin might terminate the session at any time. It is a lot more efficient to build a framework that expects any given call to potentially fail. – sfdcfox Dec 19 '18 at 16:18

Browse other questions tagged or ask your own question.