function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Andre Khoi Nguyen DoAndre Khoi Nguyen Do 

Access token expiry duration

What is the access token expiry duration? (Obtained by user-password flow or jwt flow)
Best Answer chosen by Andre Khoi Nguyen Do
MKRMKR
Hi,

It is the same as Session timeout value in Setup -> Session Settings. See this discussion for more details:
https://salesforce.stackexchange.com/questions/73512/oauth-access-token-expiration

Regards,
Miika

All Answers

MKRMKR
Hi,

It is the same as Session timeout value in Setup -> Session Settings. See this discussion for more details:
https://salesforce.stackexchange.com/questions/73512/oauth-access-token-expiration

Regards,
Miika
This was selected as the best answer
Deepali KulshresthaDeepali Kulshrestha
Hi Andre,

Please follow the given below points and links with the help of these, you can solve your problem, it may be helpful to you.

1. Sessions expire based on your organization's policy for sessions. As long as the app is in active use, the session won't expire. Once the session is logged out, the timeout has elapsed, or it is otherwise expired (e.g. an administrator expires all sessions for the Connected App).

2. There's no way to know how long it will be until your session expires. It's not exactly "trial and error," it is simply a normal process. Even if you were told that your session expired in two hours, it might not last two hours if an administrator revokes the session, the session remains in use, etc.

3. If you use refresh tokens, your code should first try the regular API call, and if you get a 4xx result, try using the refresh token to get a new session token, and if that fails, then you've been kicked out, and the user needs to re-authenticate to continue. If you don't use refresh tokens, you can skip the middle step, obviously
 
For more information Please follow the given below link:

Link: http://salesforce.stackexchange.com/questions/73512/oauth-access-token-expiration
Link: https://developer.salesforce.com/forums/?id=906F00000009CYiIAM 
Link: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_understanding_refresh_token_oauth.htm

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
Ajay K DubediAjay K Dubedi
Hi Andre,

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. I think it's same as we are having limit for normal API in Salesforce. Take a look here for more information  https://salesforce.stackexchange.com/questions/73512/oauth-access-token-expiration

Thanks,
Ajay Dubedi