title: Google API Error - "The OAuth client was not found"
body: <p>I tried to get statistics from google analytics with php without success. The code is following and the error is after when i trying to refresh the token </p>
  
  <blockquote>
    <p>Fatal error: Uncaught Google_Auth_Exception: Error refreshing the
    OAuth2 token, message: '{ "error" : "invalid_client",
    "error_description" : "The OAuth client was not found." }'</p>
  </blockquote>
  
  <pre><code>$service_account_email = $this-&gt;settings-&gt;service_account_email;
  $key_file_location = LOCALPATH.'plugins/google-api-php-client/client_secrets.p12';
  
  $client = new Google_Client();
  $client-&gt;setApplicationName("GetStats");
  
  $client-&gt;setAccessType('offline');
  $analytics = new Google_Service_Analytics($client);
  
  $key = file_get_contents($key_file_location);
  $cred = new Google_Auth_AssertionCredentials(
    $service_account_email,
    array(Google_Service_Analytics::ANALYTICS_READONLY),
    $key
  );
  
  $client-&gt;setAssertionCredentials($cred);
  
  if($client-&gt;getAuth()-&gt;isAccessTokenExpired()) {
     $client-&gt;getAuth()-&gt;refreshTokenWithAssertion($cred);
  }
  
  return $analytics;
  </code></pre>
  
  <p>I think that the problem is in the google api console, but i can't catch it.</p>
  
  <p>PS: If you have an easier option to get google statistics (with php or javascript) I will glad to try it</p>