【问题标题】:Google Analytics Management Api Insert Goal: 403 Insufficient permission .netGoogle Analytics Management Api 插入目标:403 Insufficient permission .net
【发布时间】:2018-01-12 08:04:35
【问题描述】:

我收到了来自 Google Analytics 团队的关于项目白名单的确认电子邮件,并尝试插入一个目标,但收到了错误。

{The service analytics has thrown an exception: Google.GoogleApiException: Google.Apis.Requests.RequestError
Your project does not have access to this feature. [403]
Errors [
        Message[Your project does not have access to this feature.] Location[ - ] Reason[insufficientPermissions] Domain[global]
]

   at Google.Apis.Requests.ClientServiceRequest`1.<ParseResponse>d__34.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Google.Apis.Requests.ClientServiceRequest`1.Execute()}

我正在使用 Google.Apis.Analytics.v3 (1.32) nuget 包来创建目标

我写的代码是:

            var goal = new Goal();
            goal.AccountId = accId;
            goal.WebPropertyId = websiteId;
            goal.ProfileId = profileId;

            goal.Name = "Api Funnel";
            goal.Active = true;
            goal.Created = new DateTime();


            goal.Type = "URL_DESTINATION";
            var urlDestinationDetails = new UrlDestinationDetailsData();
            urlDestinationDetails.MatchType = "EXACT";

            var stepData0 = new UrlDestinationDetailsData.StepsData();
            stepData0.Number = 0;
            stepData0.Url = "step1";
            stepData0.Name = "Step1";

            var stepData1 = new UrlDestinationDetailsData.StepsData();
            stepData1.Number = 0;
            stepData1.Url = "step2";
            stepData1.Name = "Step2";

            var steps = new List<UrlDestinationDetailsData.StepsData>();

            urlDestinationDetails.Steps = steps;
            goal.UrlDestinationDetails = urlDestinationDetails;
            goal.UrlDestinationDetails.Url = "step2";
            var request = analyticsService.Management.Goals.Insert(goal, accId, websiteId, profileId);
            request.Execute();

范围设置为 analytics.edit :

https://www.googleapis.com/auth/analytics.edit

我还是遇到了这个问题

google analytics management api - Insert goals - 403

也参考了相应的帖子,但找不到任何答案。

所有获取请求均已成功处理并返回正确的数据。 现在,我想插入一个目标,但遇到了这个问题。

也使用谷歌的问题跟踪器询问

https://issuetracker.google.com/issues/71837169

开发者论坛组现在也关闭了:https://groups.google.com/forum/?fromgroups#!forum/google-analytics-management-api

请随时询问任何其他信息。

【问题讨论】:

  • 我自己使用 Google API 的经验是您需要一个 p12 密钥和一个帐户。你设置了吗?
  • @MatthewEvans 仅当您想使用服务帐户访问时才是正确的,它不会帮助您访问用户数据。

标签: c# google-analytics google-api google-analytics-api google-api-dotnet-client


【解决方案1】:

Documentation

Web 媒体资源、视图(配置文件)和目标资源的 Management API 中的写入操作(例如创建、更新、删除、修补)目前在有限的测试版中作为开发者预览版提供。如果您有兴趣使用这些功能,请申请测试版。

Google Analytics(分析)写入操作处于测试阶段。您说您已申请并被列入白名单。您必须使用您申请的 Google Developer Project 才能访问它。

您的项目无权访问此功能。

意味着您用来进行身份验证的客户端 ID 和密码无权访问此功能,它不是您申请访问白名单的项目的一部分。

【讨论】:

  • **授权此请求需要具有以下范围的授权(阅读有关身份验证和授权的更多信息)。范围googleapis.com/auth/analytics.edit ** 这是在developers.google.com/analytics/devguides/config/mgmt/v3/… 中提到的范围,另外,clientid 以我要求列入白名单的项目编号开头,例如 clientid-ftv69u9f7iltciu9bsvi5u66aeium962.apps.googleusercontent.com 所以,我确信它是正确的。还有什么我可能会丢失的吗? @DalmTo
  • 通过您受邀加入的 Google 群组联系 Google。听起来您的白名单项目可能存在一些问题。消息说,据我所知,该项目未列入白名单,范围不存在
  • 终于成功了,可能是项目的白名单有问题。感谢您的帮助@DalmTo :)
  • 他们可能不会给予太多访问权限。白名单可能需要一段时间。顺便说一句,我用谷歌检查过 googleapis.com/auth/analytics.edit 是一个有效的范围。如果它对您有帮助,请记住接受答案
猜你喜欢
  • 2015-10-15
  • 2013-10-25
  • 2015-11-15
  • 2013-10-15
  • 1970-01-01
  • 2022-12-02
  • 2015-12-28
  • 2016-09-04
  • 1970-01-01
相关资源
最近更新 更多