首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >谷歌分析v3 Google.Apis.Requests.RequestError用户没有任何谷歌分析帐户。[403] [=宋体]

谷歌分析v3 Google.Apis.Requests.RequestError用户没有任何谷歌分析帐户。[403] [=宋体]
EN

Stack Overflow用户
提问于 2013-05-08 03:31:24
回答 1查看 3.6K关注 0票数 0

我正在使用谷歌分析的v3应用程序接口的一些自动化的报告谷歌分析数据。

代码语言:javascript
复制
string scope_url = "https://www.googleapis.com/auth/analytics.readonly";
string client_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com";
string key_file = @"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-privatekey.p12";
string key_pass = "notasecret";
AuthorizationServerDescription desc = GoogleAuthenticationServer.Description;
//key: Load up and decrypt the key
X509Certificate2 key = new X509Certificate2(key_file, key_pass, X509KeyStorageFlags.Exportable);
//client: we're using the AssertionFlowClient, because we're logging in with our certificate
AssertionFlowClient client = new AssertionFlowClient(desc, key) { ServiceAccountId = client_id, Scope = scope_url };
OAuth2Authenticator<AssertionFlowClient> auth = new OAuth2Authenticator<AssertionFlowClient>(client, AssertionFlowClient.GetState);
//gas: An instance of the AnalyticsService we can query
// AnalyticsService gas = null;// new AnalyticsService(auth);//not compile
var gas = new AnalyticsService(new BaseClientService.Initializer()
       {
                    Authenticator = auth
       });
//r: Creating our query
DataResource.GaResource.GetRequest r = gas.Data.Ga.Get("ga:xxxxxxxx", "2012-09-26", "2012-10-10", "ga:visitors");
//d: Execute and fetch the results of our query
GaData d = r.Fetch();

我收到错误Google.Apis.Requests.RequestError User does not have any Google Analytics account. [403] Errors [ Message[User does not have any Google Analytics account.] Location[ - ] Reason[insufficientPermissions] Domain[global]]

使用相同的帐户,当我通过简单的api访问使用v2.4版本实现时,它是工作的。不知道为什么它适用于v2.4版本,而不适用于v3版本的analytics api。

在google api控制台中,我已将Analytics API和google API服务设置为on

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-08 14:10:50

我能够从google分析界面中提取数据,在上面的代码中添加了电子邮件ID和客户端id。链接https://groups.google.com/forum/#!msg/google-analytics-data-export-api/maa_fyjD2cM/2ZxM52BinmUJ中提供了详细信息

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16427059

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档