【问题标题】:Google analytics v3 Google.Apis.Requests.RequestError User does not have any Google Analytics account. [403]Google Analytics v3 Google.Apis.Requests.RequestError 用户没有任何 Google Analytics 帐户。 [403]
【发布时间】:2013-05-01 21:06:49
【问题描述】:

我正在使用谷歌分析 v3 api 来自动报告谷歌分析数据。

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 版本的分析 api。

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

【问题讨论】:

    标签: .net google-analytics google-analytics-api


    【解决方案1】:

    在从谷歌分析界面添加电子邮件 ID [在上面的代码客户端 ID 中] 后,我能够提取数据。 详情见链接https://groups.google.com/forum/#!msg/google-analytics-data-export-api/maa_fyjD2cM/2ZxM52BinmUJ

    【讨论】:

    • 事实上,对于一个谷歌分析注册,我有几个帐户正在为两个不同的网站获取数据。我必须将该电子邮件帐户注册到两个帐户
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-30
    • 2020-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-12
    相关资源
    最近更新 更多