使用Google AnalyticsAPI访问服务帐户 [英] Google Analytics API access with a service account

查看:121
本文介绍了使用Google AnalyticsAPI访问服务帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用客户端应用程序中的服务帐户访问Google Analytics数据吗?如果没有,是否还有其他方法可以达到相同的结果?



必须完全是客户端,并且不得要求用户进行身份验证(因此希望使用服务帐户)。

解决方案

是的,您可以在 https://code.google.com/apis/console 确保你说它的服务帐号会给你一个关键文件下载。因此,您不需要用户单击确定即可授予您访问权。



对于需要工作的服务,您需要有一个密钥文件。任何有权访问该密钥文件的人都可以访问您的Google Analytics数据。 Javascript是客户端,这意味着您将需要发送密钥文件。看到问题了吗?您正在向每个人提供对您帐户的访问权限。即使你可以得到一个服务帐户使用JavaScript出于安全原因,它可能不是一个好主意。

Can I access Google Analytics data using a service account in a client-side application? If not, are there other ways of achieving the same outcome?

Must be entirely client-side, and must not require users to authenticate (hence the desire to use a service account).

解决方案

Yes you can in https://code.google.com/apis/console make sure you say that its a Service account it will give you a key file to download. With that you dont need a user to click ok to give you access.

For a service acccount to work you need to have a key file. Anyone that has access to that key file will then be able to access your Analytics data. Javascript is client sided which means you will need to send the key file. See the Problem? You are handing everyone access to your account. Even if you could get a service account to work using javascript for security reasons its probably not a very good idea.

这篇关于使用Google AnalyticsAPI访问服务帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆