title: Persisting the refresh token of the Spring OAuth2RestTemplate
body: <p>I have a <strong>mobile application</strong> that uses my <strong>Spring Boot backend</strong> for things like authentication and accessing data. A part of the Spring Boot application accesses data from a resource server using OAuth2. I stumbled across an <a href="https://spring.io/guides/tutorials/spring-boot-oauth2/#_social_login_manual" rel="nofollow noreferrer">oauth2 client library</a> for Spring that does its magic and everything just works out of the box.</p>
  
  <p>As I'm trying to figure out how this library does its work, I can't seem to find an answer to the way it handles refresh tokens. I'm aware that the oauth2client is bound to a session for each user but what happens when the session ends? Wouldn't the access and refresh tokens get lost?</p>
  
  <p>I was looking for ways to persist the refresh token for each user in my database but I didn't find any support for that in the library. This leaves me wondering if I have to implement this myself or if there's even a need to do so.</p>
  
  <p>Any advice is appreciated!</p>