title: YouTube Analytics API PHP: usageLimits accessNotConfigured
body: <p>I am using the [Google Analytics API PHP] by wanze. I was able to set up authentication (using web auth only) and everything and I stored the token in a session. On another page, I use this code to find all the accounts the user logged in with.</p>
  
  <pre><code>session_start();
  include('GoogleAnalyticsAPI.class.php');
  
  $ga = new GoogleAnalyticsAPI(); 
  $ga-&gt;auth-&gt;setClientId('replaces'); // From the APIs console
  $ga-&gt;auth-&gt;setClientSecret('replaces'); // From the APIs console
  $ga-&gt;auth-&gt;setRedirectUri('replaced'); // Url to your app, must match one in the APIs console
  
  // Get the Auth-Url
  $url = $ga-&gt;auth-&gt;buildAuthUrl();
  
  // Set the accessToken and Account-Id
  $ga-&gt;setAccessToken($_SESSION['accessToken']);
  $ga-&gt;setAccountId('ga:xxxxxxx');
  
  // Load profiles
  $profiles = $ga-&gt;getProfiles();
  print_r($profiles);
  $accounts = array();
  foreach ($profiles['items'] as $item) {
      $id = "ga:{$item['id']}";
      $name = $item['name'];
      $accounts[$id] = $name;
  }
  // Print out the Accounts with Id =&gt; Name. Save the Id (array-key) of the account you want to query data. 
  // See next chapter how to set the account-id.
  print_r($accounts); 
  </code></pre>
  
  <p>I this returned:</p>
  
  <pre><code>Array
  (
      [http_code] =&gt; 403
      [error] =&gt; Array
          (
              [errors] =&gt; Array
                  (
                      [0] =&gt; Array
                          (
                              [domain] =&gt; usageLimits
                              [reason] =&gt; accessNotConfigured
                              [message] =&gt; Access Not Configured. The API is not enabled for your project, or there is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your configuration.
                              [extendedHelp] =&gt; https://console.developers.google.com
                          )
  
                  )
  
              [code] =&gt; 403
              [message] =&gt; Access Not Configured. The API is not enabled for your project, or there is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your configuration.
          )
  
  )
  &lt;br /&gt;
  &lt;b&gt;Warning&lt;/b&gt;:  Invalid argument supplied for foreach() in &lt;b&gt;/home3/chalzzy/public_html/dashboard/dashboard.php&lt;/b&gt; on line &lt;b&gt;21&lt;/b&gt;&lt;br /&gt;
  Array
  (
  )
  </code></pre>
  
  <p>I see in a lot of places that I need to remove or set all refers in a "Referrals" section in the console but I can't seem to fins that in the new or old console. If it is there and I can't find it, can you please give me a url or a screenshot?</p>
  
  <p>Also, these are all the APIs I have installed for this project: </p>
  
  <p><img src="https://i.stack.imgur.com/gynZ6.png" alt="List of API "></p>
  
  <p>Thanks in advance,</p>
  
  <p>Ben</p>
  
  <p><strong>Also, let me know if you need more details!</strong></p>