OAuth Refresh Token Grant
On this page
Access tokens expire quickly. A Refresh TokenA credential that an application exchanges for a new access token without asking the user to log in again. lasts longer. Your app exchanges the refresh token for a new access token without asking the user to log in again.
To issue refresh tokens, turn on Generate refresh tokens and enable Refresh Token in Enabled grants on the OAuth tab of the Application. New Applications have both settings on. Your app then gets a refresh token from the token endpoint when the request asks for the offline_access scope.
Exchange a Refresh Token for an Access Token#
Send the refresh token to the /oauth2/token endpoint with grant_type set to refresh_token. The example uses the refresh token from the Authorization Code grant example, and adds line breaks for readability.
POST /oauth2/token HTTP/1.1
Host: piedpiper.fusionauth.io
Content-Type: application/x-www-form-urlencoded
client_id=06494b74-a796-4723-af44-1bdb96b48875
&client_secret=example-client-secret-do-not-use
&grant_type=refresh_token
&refresh_token=ze9fi6Y9sMSf3yWp3aaO2w7AMav2MFdiMIi2GObrAi-i3248oo0jTQ
Replace example-client-secret-do-not-use with the Client secret from the OAuth tab of your Application.
FusionAuth returns a new access token:
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0ODUxNDA5ODQsImlhdCI6MTQ4NTEzNzM4NCwiaXNzIjoiYWNtZS5jb20iLCJzdWIiOiIyOWFjMGMxOC0wYjRhLTQyY2YtODJmYy0wM2Q1NzAzMThhMWQiLCJhcHBsaWNhdGlvbklkIjoiNzkxMDM3MzQtOTdhYi00ZDFhLWFmMzctZTAwNmQwNWQyOTUyIiwicm9sZXMiOltdfQ.Mp0Pcwsz5VECK11Kf2ZZNF_SMKu5CgBeLN9ZOP04kZo",
"expires_in": 3600,
"id_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0ODUxNDA5ODQsImlhdCI6MTQ4NTEzNzM4NCwiaXNzIjoiYWNtZS5jb20iLCJzdWIiOiIyOWFjMGMxOC0wYjRhLTQyY2YtODJmYy0wM2Q1NzAzMThhMWQiLCJhcHBsaWNhdGlvbklkIjoiNzkxMDM3MzQtOTdhYi00ZDFhLWFmMzctZTAwNmQwNWQyOTUyIiwicm9sZXMiOltdfQ.Mp0Pcwsz5VECK11Kf2ZZNF_SMKu5CgBeLN9ZOP04kZo",
"token_type": "Bearer",
"userId": "3b6d2f70-4821-4694-ac89-60333c9c4165"
}For every field, see the Refresh Token grant request.
Related
API documentation for the FusionAuth Token OAuth2 endpoint.
Learn how to log users in with the OAuth Authorization Code grant and PKCE.
Learn how DPoP binds FusionAuth access and refresh tokens to a key pair that only your client holds.
Learn about the APIs that allow you to manage Refresh Tokens, verify Access Tokens and retrieve public keys used for verifying JWT signatures.