title: How can I get an updated access token, using stored refresh token
body: <p>I'm building an application that allows the admin to authenticate access to their analytics account for offline usage, and stores the refresh token in the database.</p>
  
  <p>Now when I try to use the API on the frontend, it returns the following error: </p>
  
  <pre><code>"Access Token Expired. There wan a general error : The OAuth 2.0 access token has expired, and a refresh token is not available. Refresh tokens are not returned for responses that were auto-approved."
  </code></pre>
  
  <p>Here's my code that generates this error so far:</p>
  
  <pre><code>require_once "lib/google/Google_Client.php";
  require_once "lib/google/contrib/Google_AnalyticsService.php";
  
  $_analytics = new analytics();
  $_googleClient = new Google_Client();
  $_googleClient-&gt;setClientId($_analytics-&gt;gaClientId);
  $_googleClient-&gt;setClientSecret($_analytics-&gt;gaClientSecret);
  $_googleClient-&gt;setRedirectUri($_analytics-&gt;gaRedirectUri);
  $_googleClient-&gt;setScopes($_analytics-&gt;gaScope);
  $_googleClient-&gt;setAccessType($_analytics-&gt;gaAccessType);
  
  // Returns last access token from the database (this works)
  $_tokenArray['access_token'] = $_analytics-&gt;dbAccessToken($_agencyId);
  $_googleClient-&gt;setAccessToken(json_encode($_tokenArray));
  
  if($_googleClient-&gt;isAccessTokenExpired()) {
      // Don't think this is required for Analytics API V3
      //$_googleClient-&gt;refreshToken($_analytics-&gt;dbRefreshToken($_agencyId));
      echo 'Access Token Expired'; // Debug
  }
  
  if (!$_googleClient-&gt;getAccessToken()) {
      echo '&lt;h2&gt;Error - Admin has not setup analytics correct yet&lt;/h2&gt;';
  }
  </code></pre>
  
  <p>I'm after a function to run something like setRefreshToken - entering the value from the database, from the admin previously authenticating it online.</p>