looffee
looffee

Reputation: 81

Google Analytics Reporting API

How can I get Google Analytics report on my SPA without authorization by Google?

Without authorization as a participant of project made I get this error

403 PERMISSION_DENIED

Upvotes: 0

Views: 244

Answers (2)

Eduardo
Eduardo

Reputation: 22832

Don't do Analytics API requests for your own data at the client side.

What you should do is have a server side job that requests data from the API every day and caches the result. Then you can provide the result for clients.

The API have limits in place that avoid more than 10k requests per day, having this done at client side means that you will reach this limit. This limit is in place exactly to discourage use cases like yours.

Having this done on the client side means exposing your credentials at the client side which would also likely allow users to query data you don't intend to share or maybe even change settings in your account depending on which scopes you are authorized.

You have to rethink your design to not do this job on client side.

Upvotes: 0

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 117291

403 PERMISSION_DENIED

Means that you do not have permission to do what it is you are trying to do.

How can I get Google Analytics report on my SPA without authorization by Google?

You cant you must always be authenticated in order to access google analytics data.

In order to access private user data you must have permission to access it. Your google analytics data is private. There for you must be authorized though google in order to access that data.

If you are looking for a way of doing it without requesting access of the user. For example if you would like to display data from your personal Google analytics account to others without requiring that they have access to the data then you could use a service account. Service accounts are preauthorized so that your code will run and have access to the data without having to request access of a user.

Upvotes: 1

Related Questions