This recipe will show you how to add support for refresh tokens. As you will realize, by using Spring Security OAuth2 it becomes simple to start persisting refresh tokens, and all the logic to recognize when it's time to use the refresh token to ask for a new access token will be done by Spring Security OAuth2.
To run this recipe, make sure you have an OAuth 2.0 Provider running on your machine. I recommend you use the project auth-code-server
presented in Chapter 2, Implementing Your Own OAuth 2.0 Provider. If you have any doubts about the source code presented in this recipe, do not hesitate to download the source code available on GitHub at https://github.com/PacktPublishing/OAuth-2.0-Cookbook/tree/master/Chapter03/client-refresh-token. This recipe also relies on a database that was created in the Creating an OAuth 2.0 client using the Authorization Code grant type recipe for the client-authorization-code
project.