简体   繁体   中英

How to access Google analytics api WITHOUT logging through google login dialog (javascript)?

I can retrieve analytics data using Core Reporting API v4, but for that I am required to login through google sign in dialog.

How can I get the data skipping this step ie, I don't to want to login through the Google user interface.

Turns out I misread the question - it looks like you are looking for a service account . A service account allows for non-interactive authentication against Google APIs.

You create a service account in the Google API console. There you can download a file with credentials that are used for authentication. This is handled non-interactively without opening a browser.

You need to add the email of the service account to the resource you want to access (eg to your Analytics account).

Details are in the link (this is a PHP example, but service accounts work regardless of programming language).

Old answer:

Somebody has to log in to get the data (GA accounts always need authentication), so if you don't want to log in via the browser you need an intermediary application that authenticates against Google and then publicy exposes the data.

There is a project Google Analytics Super Proxy that does this, however it requires a bit of setup.

A simpler way would be to use the Analytics Add-On in a Google Spreadsheet, share that publicly and embed it in your page, or format the output as HTML or JSON via some Apps script and pull it into your page for display.

Unfortunately you can't.Cause you need to access the report through a private API code.And in the Javascript version, you would be sharing it with public.That's why in case of JS you MUST use the log in button.

Hence the only way to do it without logging in, is by using a server side code like PHP along with the API.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM