title: Rails / Omniauth Google API - refreshing a token
body: <p>This one is a little above my pay grade, so hopefully someone here can help!</p>
  
  <p>I'm using the <a href="https://github.com/zquestz/omniauth-google-oauth2" rel="nofollow">https://github.com/zquestz/omniauth-google-oauth2</a> gem along with Omniauth in a Rails app. A user can successfully connect through Google and grab the permissions I need. It then returns the Auth and Refresh tokens, which I am storing.</p>
  
  <p>My issue is, I can't figure out how to refresh the token when it expires. This is detailed in-depth in the documentation:</p>
  
  <p><a href="https://developers.google.com/accounts/docs/OAuth2WebServer#offline" rel="nofollow">https://developers.google.com/accounts/docs/OAuth2WebServer#offline</a></p>
  
  <p>But I cannot for the life of me figure out how to use Omniauth to check if the current token has expired, request a new one using the refresh token if so and store it.</p>
  
  <p>Thanks in advance!</p>