0

I'm working on a page that will be available to certain users where they can see shared Google Analytics data. I want to pull the data with JavaScript and I've succeeded in getting an OAuth token for the account with the GA data, but it expires in 1 hour.

How can I use this token for all users coming to the page? I don't need the users to be able to access their own GA data, just the shared data. Is there a way to make the token permanent or to refresh it?

1 Answer 1

2

Below I have listed three different possible solutions:

  1. The easiest method might be to grant permission for your desired users to have read access to the view (profile) you want to share and use the embed API to authenticate those users and display that data.

  2. You could look into using the Google Analytics Super proxy. The Google Analytics superProxy allows you to publicly share your Google Analytics reporting data. You can use it to power your own custom dashboards and widgets, transform responses to various formats, test, and much more.

  3. Or you could look into using an authenticated service account. The Google OAuth 2.0 system supports server-to-server interactions such as those between a web application and a Google service. For this scenario you need a service account, which is an account that belongs to your application instead of to an individual end user. Your application calls Google APIs on behalf of the service account, so users aren't directly involved.

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

2 Comments

Thanks for the reply. I've decided to go with step 1, although I'm going to pull the data myself so I can display it in different ways. Now I'm trying to implement sign in by calling gapi.auth.signIn({...}) but the sign in window opens and immediately closes, then returns an immediate_failed error. Any thoughts on this?
Actually the window stays open, but it immediately calls my callback function with the immediate_failed error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.