【发布时间】: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 :
我还是遇到了这个问题
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