Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Recommended use

The refresh token grant can be used when the current access token is expired or need to get when a new access token is needed. At With this grant type Refresh , the refresh token act acts as a credential and is issued to the client by the authorization server. Issuing a refresh token is optional and if the authorization server issues a refresh token, it is included when issuing an access token. WSO2 Identity Server issues refresh tokens for all other grant types other than the implicit grant as recommanded  as recommended by the specification as well.

...

OAuth 2.0 specification. 

Note

This refresh token needs to be kept private, similar to the access token. When using this token, keep in mind that it issues the access token without a user interaction.

The flow

In order to use this grant type, a refresh token needs to be already received when using a grant type like authorization code, password or client credentials. Then using this received refresh token, a new access token can be received along with a new refresh token without going through any other additional steps.

Recommanded Use:

This refresh token needs to be kept secret similar to the access token. This grant type should be used bearing in mind that, this is issuing access token without a user interaction.

Configurations:

.

Configurations

  1. The <RefreshTokenValidityPeriod> element is in seconds. By default, it is valid for one day. You can configure this accordingly. 
  2. The <RenewRefreshTokenForRefreshGrant> element is by default set to true.

    Info

    The refresh token is renewed when the refresh grant is used to get an access token. A new refresh token is issued with a new expiry time and the previous refresh token is then inactive and can no longer be used.

    If this element is set to false, unless the refresh token has expired, the same refresh token is returned.

Code Block
themeEclipse
languagexml
		<!-- Validity period for refresh token -->
		<RefreshTokenValidityPeriod>84600</RefreshTokenValidityPeriod>
		...
        <!-- Enable renewal of refresh token for refresh_token grant -->
        <RenewRefreshTokenForRefreshGrant>true</RenewRefreshTokenForRefreshGrant>
  • RefreshTokenValidityPeriod is mentioned in seconds. By default it is valid for one day.
  • By default "RenewRefreshTokenForRefreshGrant" set to true,
      • we renew the refresh token when refresh grant is used to get an access token --> a new refresh token is issued with a new expiry time
      • previous refresh token is then inactive and can no longer be used
    • If set false,

 

Try Out Scenario with cURL:

 

Try out scenario

Run the following cURL command to try out the refresh token grant. 

Code Block
languagepowershell
curl -k -d "grant_type=refresh_token&refresh_token=<refresh_token>" -H "Authorization: Basic <Base64Encoded(Client_Id:Client_Secret)>" -H "Content-Type: application/x-www-form-urlencoded" https://localhost:9443/oauth2/token

 

 

 

 

...