4
votes

I'm trying to get the Google Analytics API to work and have started with the basic tutorial from Google in PHP.

For some reason, I keep getting the following error message:

Error calling GET https://www.googleapis.com/analytics/v3/management/accounts?key=my_developer_key_from_the_console: (403) Access Not Configured

I couldn't find any solution to this, mainly because I believe I've set everything up correctly:

  • The Analytics API is turned “on” in my Google Console
  • OAuth2 works fine. I receive an access token.
  • My quota hasn't been reached - not even close.

What am I missing?

3

3 Answers

2
votes

You dont pass the key from apis console to

https://www.googleapis.com/analytics/v3/management/accounts?

you should be passing the access token that you got from oauth.

https://www.googleapis.com/analytics/v3/management/accounts?oauth_token={yourtoken}
1
votes

I got the same error and i fixed it by enable the Google plus api from google console.

0
votes

I had this problem too. Interestingly, if you don't use the client library and simply use a cURL request instead with your access_token appended, it works and JSON is returned.

At least by using cURL you can be sure if it really is your configuration, or its something that the client library is doing.

$url = 'https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties/~all/profiles';
// json decode as array
$analytics_auth = json_decode($_SESSION['access_code'], true);

$ch = curl_init($url . '?access_token=' . $analytics_auth['access_token']);
curl_exec($ch);
curl_close($ch);