Google Analytics API v3 authorization to allow access to my data

V S picture V S · Mar 29, 2012 · Viewed 12.2k times · Source

I am developing an app that allows users to see my own Google Analytics Data using Google API v3. Everything I researched seems to indicate that users need to login into their Google accounts and grant my app the access before I can start querying the API; however, that's not what I want, I just need my users to see my own Analytics data. How can authorize the API to access my data. I have the client ID and Client Secret, but the OAuth that's implemented by Google's API v3 is asking for an authorization token, which can only be obtained by getting the user to login into their google account (is that right?) Is there a way to just login into my own Google Analytics account and display that information to the users?

Answer

nemaroller picture nemaroller · Apr 11, 2013

I believe what you want to do is set up a Service Account: https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtAuthorization

"Useful for automated/offline/scheduled access to Google Analytics data for your own account. For example, to build a live dashboard of your own Google Analytics data and share it with other users.

There are a few steps you need to follow to configure service accounts to work with Google Analytics:

  1. Register a project in the APIs Console.
  2. In the Google APIs Console, under the API Access pane, create a client ID with the Application Type set to Service Account.
  3. Sign-in to Google Analytics and navigate to the Admin section.
  4. Select the account for which you want the application to have access to.
  5. Add the email address, from the Client ID created in the APIs Console from step #2, as a user of the selected Google Analytics account.
  6. Follow the instructions for Service Accounts to access Google Analytics data: https://developers.google.com/accounts/docs/OAuth2ServiceAccount"