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?
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:
- Register a project in the APIs Console.
- In the Google APIs Console, under the API Access pane, create a client ID with the Application Type set to Service Account.
- Sign-in to Google Analytics and navigate to the Admin section.
- Select the account for which you want the application to have access to.
- 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.
- Follow the instructions for Service Accounts to access Google Analytics data: https://developers.google.com/accounts/docs/OAuth2ServiceAccount"
You can use a refresh token
for offline access. Once you get the refresh token
, you can save it to a file or database and use that to access the data without an authorization redirect.
See Using a Refresh Token in the docs.
Also see: How can we access specific Google Analytics account data using API?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With