Refreshing a token
When an access token obtained by client application has expired, client application can utilize "refresh token” To obtain a new access token. Client application can make a HTTP Post request (from server side – aka not from browser as this request requires passing client secret) at OpenID Connect/OAuth token server to obtain a new access token. Parameters will be client id, client secret, grant_type = refresh_token and refresh_token.
HTTP response code received on refresh token request | Description |
|---|
| 200 | Client authentication successful, refresh token is valid. Response contains new access token along with expires_in for the new token. |
| 400 | Bad request – implying either invalid or expired refresh token or one of the desired input parameters are missing in request. |
| 401 | Client authentication failure – invalid client_id or client_secret. |
Additional information:
- The response payload contains a new refresh token. Client application must re-store this new refresh token for another access token refresh token endpoint call in the future.
- There is no restriction to how many times a client application can call token endpoint to refresh access token. However, new refresh token will have the same absolute expiration timing as the original refresh token (i.e. calling token endpoint does not extend the absolute expiration timing of the refresh token, for security reasons).
- As a best practice – client application should use refresh token only when the previously obtained access token has expired.
- The “expires_in” for access token obtained from the use of refresh token will mostly be same as the original access token obtained – however it’s advisable for client application to be dynamic enough and read the “expires_in” value every time a new access token is obtained and accordingly schedule the refresh task.