title: Auth Google Analytics PHP API
body: <p>I have tried the official <a href="https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/service-php#helloanalyticsphp" rel="nofollow">HelloAnalytics</a> tutorial however it doesn't work.</p>
  
  <p>I am recieveing this error: </p>
  
  <blockquote>
    <p>"PHP Fatal error:  Class 'Google_Auth_AssertionCredentials' not found" </p>
  </blockquote>
  
  <p><strong>My Code:</strong></p>
  
  <pre><code>  // Creates and returns the Analytics service object.
  
    // Load the Google API PHP Client Library.
     require_once 'vendor/autoload.php';
  
    // Use the developers console and replace the values with your
    // service account email, and relative location of your key file.
    $service_account_email = 'xxxxxxxxxxx@gmail.com';
     $key_file_location = 'key_anyl.p12';
  
   // Create and configure a new client object.
    $client = new Google_Client();
    $client-&gt;setApplicationName("HelloAnalytics");
     $analytics = new Google_Service_Analytics($client);
  
   // Read the generated client_secrets.p12 key.
    $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);
    }
  </code></pre>
  
  <p><strong>Update:</strong>  </p>
  
  <p>after adding the suggested V1-master branch I am now getting the following error </p>
  
  <blockquote>
    <p>Uncaught exception 'Google_Service_Exception' with message 'Error
    calling GET googleapis.com/analytics/v3/management/accounts: (403)
    User does not have any Google Analytics account.'</p>
  </blockquote>