0

I need to write a web app for a marketing company which needs to connect to their customers websites to access Google analytics data and store it in their database. I follow the example provided by Google at: https://developers.google.com/analytics/solutions/articles/hello-analytics-api I created the following Client id at Google API console

Client ID: 915242733409.apps.googleusercontent.com Email address: [email protected] Client secret: xxx Redirect URIs: http://thefridgedoors.net/google-analytics/google-api-php-client/examples/analytics/simple.php JavaScript origins: https://www.thefridgedoors.net 

My app's authentication looks as follows:

/* Start a session to persist credentials */ session_start(); /* Create and configure a new client object */ $client = new Google_Client(); $client->setApplicationName("Google+ PHP Starter Application"); // Visit https://code.google.com/apis/console to generate your // oauth2_client_id, oauth2_client_secret, and to register your oauth2_redirect_uri. $client->setClientId('915242733409.apps.googleusercontent.com'); $client->setClientSecret('…'); $client->setRedirectUri('http://thefridgedoors.net/google-analytics/example1.php'); $client->setDeveloperKey('…'); $client->setScopes(array('https://www.googleapis.com/auth/analytics.readonly')); 

However I get the following error: There wan a general error :

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

Any hint on what might be wrong?

1
  • You should reset the API keys that you posted here. I have removed them from your post, but they could have been stolen before I got here and they can still be viewed by SO users with sufficient knowledge. Commented Jan 12, 2014 at 5:36

1 Answer 1

2

You need to enable the Analytics API for your project in the Google APIs Console. Open your project, select the Services tab, and then click on the switch under the Status column for the Analytics API.

P.S. you might want to avoid publishing your client secrets.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.