title: OAuth v2 (Google API) expiry Access Token
body: <p>I am building an integration component using a graphical framework who has a pre-build OAuth2 connector.
  This framework required following fields for OAuth v2:</p>
  
  <ul>
  <li>Grant type</li>
  <li>Scope</li>
  <li>Auth Server URL</li>
  <li>Client Id</li>
  <li>Client Secret</li>
  <li>Access Token </li>
  <li>Refresh token</li>
  </ul>
  
  <p>I need to get data from Google Analytics API, so I went to Google Dev Console
  (<a href="https://console.developers.google.com/project/927890000889/apiui/credential" rel="noreferrer">https://console.developers.google.com/project/927890000889/apiui/credential</a>). I generated a 'Client ID for web application'. From the parameter of this object I was able to fill some of the parameters above</p>
  
  <ul>
  <li>Grant type : 'authorisation_code'</li>
  <li>Client Id : 'RANDOMCHARSam5o37nsiu730d.apps.googleusercontent.com'</li>
  <li>Client Secret : 'RANDOMCHARSiSwBA5OH5qYLUa'</li>
  </ul>
  
  <p>Then using Google Oauth Playground (<a href="https://developers.google.com/oauthplayground" rel="noreferrer">https://developers.google.com/oauthplayground</a>) I was able to fill the missing bits</p>
  
  <ul>
  <li>Scope : '<a href="https://www.googleapis.com/oauth/analytics" rel="noreferrer">https://www.googleapis.com/oauth/analytics</a>'</li>
  <li>Auth Server URL : '<a href="https://accounts.google.com/o/oauth2/auth" rel="noreferrer">https://accounts.google.com/o/oauth2/auth</a>'</li>
  <li>Access Token : 'RANDOMCHARSQAQv4HRF5-JsQEzUS61lj2YremyCocv0PQ4-agpzJe'</li>
  <li>Refresh token : 'RANDOMCHARSLPJnL4FPaDc2KP6V8kCzjjHO2Kj4Np_3X0'</li>
  </ul>
  
  <p>Everything works fine, I am authorised to access and I get data from Google Analytics, but just for a while, after few minutes if I retry I receive an authorisation failure error.
  I believe that the problem is related to the expiration of the Access Token, but I don't know how to solve that.
  Worth to mention that this activity it's batch (no human interaction), so nobody can request a new access token.
  The integration framework is not extensible (I cannot write code to renew the code) so I believe there's a way to get a access token that never expire or some other mechanism to achieve the same result.</p>
  
  <p>Bottom line, I am not sure if I approached the requirement correctly since the beginning (Client ID for web application).</p>
  
  <p>Any help is much appreciated, 
  Giovanni</p>