Slaesforce FAQ

how long does salesforce refresh token expiration

by Fabiola Dicki 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.

The refresh token is used indefinitely, unless revoked by the user or Salesforce admin.

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.

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.

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

image

How long is refresh token valid?

The Refresh token has a sliding window that is valid for 14 days and refresh token's validity is for 90 days.

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.

How do I know if my refresh token is expired?

If you look in the dashboard application settings, you can see the Refresh Token expiration time. By default, it is 720 hours (2592000 seconds).

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 increase token expire time?

Update Access Token LifetimeGo to Dashboard > Applications > APIs and click the name of the API to view.Locate the Token Expiration (Seconds) field, and enter the appropriate access token lifetime (in seconds) for the API. Default value is 86,400 seconds (24 hours). ... Click Save Changes.

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.

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.

How do I refresh a 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 does refresh token work?

Refresh Tokens are credentials used to obtain access tokens. 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.

Can I use refresh token multiple times?

Re: How many times can we use a Refresh token If you're talking about old refresh token, it only available one time.

Can a token be used twice?

You trade that OAuth Token in for an Access Token that you can use to access the API and site at any time. Once that OAuth Token has been traded in for an Access Token it can't be used again, but the Access Token can.

Should you store refresh tokens?

The client needs to store the refresh token safely. A malicious attacker gets access to the refresh and access token and uses it to request protected data to the resource server. The malicious attacker can get protected data from the resource server.

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.

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

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.

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)

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.

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.

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.

Salesforce Grants a New Access Token

After verifying the request, Salesforce sends a response with a new access token to the connected app.

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