Slaesforce FAQ

how long does salesforce refresh token last

by Weldon Herzog Published 2 years ago Updated 2 years ago
image

Refresh tokens will expire X days (or hours) after their creation. Depending on your security requirements this expiration will be 1 month or 1 hour. You have to make the decision taking care some aspects as functionality and security.

2 hours

Full Answer

How long does a Salesforce access token last?

In our experience at Xkit, Salesforce Access Tokens typically expire in 2 hours (7,200 seconds), but this value is not guaranteed to be static—Salesforce could change it at any time with no warning. So what do you do? You have two options:

Do refresh tokens expire?

Refresh tokens may or may not have expiry time, depending on your provider they expire never, not as long as they're recently used, in months or in hours. Relying on the fact that you will receive new refresh token with refreshed access token may be tricky. Timeout is not the only way in which token may become invalid.

How do I use refresh tokens for session authentication?

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

What is expires_in in Salesforce OAuth?

According to the OAuth 2.0 spec the expires_in parameter is included with the Access Token response and provides the lifetime of the returned token in seconds. And while this parameter is extremely common in OAuth implementations, it is merely recommended and not required. The Salesforce OAuth implementation does not use this parameter.

image

How long should a refresh token live?

The refresh token is set with a very long expiration time of 200 days. If the traffic to this API is 10 requests/second, then it can generate as many as 864,000 tokens in a day.

Is refresh token permanent?

The Google Auth server issued Refresh tokens never expire — that's the whole point of the refresh tokens. The refresh token will expire (or I should say become unauthorized) when the user revokes access to your application.

Does Salesforce security token expire?

Salesforce Access Tokens/Session IDs expire only during periods of inactivity. The window is automatically refreshed for a token if it is used at least 50% of the way through its expiration. For example, if a token has a 2 hour life, and you make an API call at 59 minutes, it will expire in 1 hour, 1 minute.

How does refresh token expire?

When enabled, a refresh token will expire based on a specified inactivity lifetime, after which the token can no longer be used. Enter Inactivity Lifetime in seconds. If the refresh token is not exchanged within the specified interval, the refresh token expires and can no longer be used to get a new access token.

Does token expire?

As mentioned, for security purposes, access tokens may be valid for a short amount of time. Once they expire, client applications can use a refresh token to "refresh" the access token.

What is sliding refresh token lifetime?

Sliding: when refreshing the token, the lifetime of the refresh token will be renewed (by the amount specified in SlidingRefreshTokenLifetime). The lifetime will not exceed the absolute lifetime.

How do I refresh my Salesforce token?

Request an Updated Access Token. A connected app can use the refresh token to get a new access token by sending one of the following refresh token POST requests to the Salesforce token endpoint. The connected app can send the client_id and client_secret in the body of the refresh token POST request, as shown here.

How do I revoke a refresh token in Salesforce?

You would call https://login.salesforce.com/services/oauth2/revoke?token={DeleteToken} to trigger the revocation. Note that depending on how your connected app is implemented, this could cause problems, as the token exchange process breaks down. The app would have to ask the user to authenticate again.

How do I find my Salesforce security token?

To gain access to your security token, go to “Setup” (appears in the top right corner, under your name). In the left side menu column (under Personal Setup), open the drop down item “My Personal Information.” The option to reset your security token will appear right under password reset option.

How many times can a refresh token be used?

A Refresh Token is valid for 60 days and can be used to obtain a new Access Token and Refresh Token only once. If the Access Token and Refresh Token are not refreshed within 60 days, the user will need to be re-authorized.

How do I check if my refresh token is expired?

Use Refresh Token Rotation This means that the frontend code can rely on the SDK to manage Refresh Tokens' exchange for new Access Tokens. If you look in the dashboard application settings, you can see the Refresh Token expiration time.

How often should you refresh token?

The most secure option is for the authorization server to issue a new refresh token each time one is used. This is the recommendation in the latest Security Best Current Practice which enables authorization servers to detect if a refresh token is stolen.

How long does Salesforce token expire?

In our experience at Xkit, Salesforce Access Tokens typically expire in 2 hours (7,200 seconds), but this value is not guaranteed to be static—Salesforce could change it at any time with no warning.

Does Salesforce use OAuth?

If you're building a Salesforce integration into your app, particularly a "Connected App" style of integration, and your integration uses OAuth to get access to Salesforce's REST APIs, you may be wondering when the access tokens issued by Salesforce expire.

Does Salesforce have an expires_in parameter?

That's right! While Salesforce does not include an expires_in parameter, they do have a special token introspection endpoint as part of the extension to the OAuth 2.0 spec. This endpoint ( Salesforce docs here) returns a JSON object that includes an exp property. This exp corresponds to the exp claim of the JWT spec. Unlike the expires_in parameter, exp is a Unix epoch timestamp.

What does authorization server do?

The authorization server MUST verify the binding between the refresh token and client identity whenever the client identity can be authenticated. When client authentication is not possible, the authorization server SHOULD deploy other means to detect refresh token abuse.

What is refresh token?

Refresh tokens are issued to the client by the authorization server and are used to obtain a new access token when the current access token becomes invalid or expires, or to obtain additional access tokens with identical or narrower scope (access tokens may have a shorter lifetime and fewer permissions than authorized by the resource owner)

Why is my refresh token no longer valid?

Some of the reasons a refresh token may no longer be valid include: the authorization server has revoked the refresh token. the user has revoked their consent for authorization. the refresh token has expired.

How long does a refresh token last?

Does this mean that the refresh_token will be indefinitely valid or does it expire: 1 X days after being issued; or 2 X days after the last use of it for obtaining a new access_token

Do refresh tokens expire?

Refresh tokens may or may not have expiry time, depending on your provider they expire never, not as long as they're recently used, in months or in hours. Relying on the fact that you will receive new refresh token with refreshed access token may be tricky.

How long does a security expiration last?

Depending on your security requirements this expiration will be 1 month or 1 hour. You have to make the decision taking care some aspects as functionality and security. If you decide to priorize security, a short expiration could make your application anoying for the user.

image
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9