title: How to handle expiring refresh tokens in spring boot rest template client
body: <p>I'm working on integrating a third party API in my spring boot application.</p>
  
  <p>How the third party API authentication works:</p>
  
  <ol>
  <li>After initial authorisation, I'm provided with refresh token and
  access token that expires after a given time</li>
  <li>After the access token expires I use the refresh token to get a new access token AND a new refresh token</li>
  </ol>
  
  <p>With the current access token I can make calls to the API.</p>
  
  <p>Is there a way to seamlessly handle such case using RestTemplate?</p>
  
  <p>I've tried handling this case manually, so if I got 401 back from the API I sent a refresh token request, rewrote the keys I got back and retried the request, not really sure how to handle storing the api keys in case I need to restart the server.</p>