3

My application needs to fetch Google Analytics data from backend servers.

I am using Google Service Account in my application. Though I have given all permissions to my service account through Google Developer console, it turns out that my service account cannot access custom segments of my user account.

A way could have been to copy these segments from user account to service account, but there seems like no way to login via service account and be able to copy segments from user account to service account.

So, there seems like no way to be able to fetch custom segments in a web application from backend...

Is there any way to do so? Can any other account(web application, Installed application account) serve my purpose? Reading the documentation of above two Google accounts reveals that user would be prompted for authentication (at least once) during authorization in these 2 accounts which is not feasible in backend servers.

I found a similar thread for my query Google Analytics V3 - How to create custom segments for API Service Accounts , but user in this thread resorted to not using segments at all, but I do need to use them in my account.

PS: I am writing my application in RubyOnRails and would be using Ruby Gem for Google Authentication

4

1 回答 1

2

答:不,无法将分段添加到服务帐户。即使是 Mangment api 也只允许您列出段而不添加它们。 分段管理 API文档

一个想法:您可以使用您的帐户使用普通的 Oauth2 对其进行身份验证,将刷新令牌保存在某个地方并在您的应用程序中使用它来查看数据。然后就像应用程序始终是您并且能够看到您的细分市场。

抱歉,我不了解 ruby​​,所以我无法帮助您实现这个想法。

于 2014-10-22T09:14:18.837 回答