Should I explicitly send the Refresh Token to get a new Access Token – JWT

Yes, the refresh token is used to obtain a new access token.

When you request the access token for the first time, you usually start by sending a token request to the token endpoint, in case of the so called Resource Owner Password Credentials Grant with user credentials in the request header, e.g.

grant_type=password&username=user1&passowrd=very_secret

when the access token is expired, you have to request a new access token. This time, with a refresh token which is still valid, you don’t need the user credentials again but send

grant_type=refresh_token&refresh_token=<your refresh token>

instead.
This way you don’t need to store the user credential on client side and don’t need to bother the user again with a login procedure.
As you know the expiry time, you can also implement a mechanism to refresh your token before the access_token is expired.

Additionally you can read this for further information about the topic: https://auth0.com/learn/refresh-tokens/

In the following tutorial is also a screenshot of how to use refresh token in postman: http://bitoftech.net/2014/07/16/enable-oauth-refresh-tokens-angularjs-app-using-asp-net-web-api-2-owin/ (scroll down to step 6)
Generally I can recommend reading Taiseer Joudeh’s tutorial, esp. for C#, ASP.NET uand Angular programmers.

Leave a Comment