首页 > 解决方案 > Analytics Reporting API 之前未在项目中使用过或已禁用

问题描述

错误:googleapiclient.errors.HttpError: <HttpError 403 when requesting https://analyticsreporting.googleapis.com/v4/reports:batchGet?alt=json returned "Analytics Reporting API has not been used in project 190831311549 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/analyticsreporting.googleapis.com/overview?project=xxxx then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.". Details: "[{'@type': 'type.googleapis.com/google.rpc.Help', 'links': [{'description': 'Google developers console API activation', 'url': 'https://console.developers.google.com/apis/api/analyticsreporting.googleapis.com/overview?project=xxxx'}]}]">

脚步:

  1. 在云控制台启用 Google Analytics Reporting API
  2. 创建服务凭证并将电子邮件作为读取/分析用户添加到 GA 帐户
  3. 我正在使用“Hello Analytics Reporting API V4”。蟒蛇代码
  4. 使用apiclient.discoveryanalytics = build('analyticsreporting', 'v4', credentials=credentials, cache_discovery=False)
  5. 我还尝试了绕过我的python代码的解决方法https://developers.google.com/analytics/devguides/reporting/core/v4/rest/v4/reports/batchGet但是当我尝试执行身份验证弹出窗口时空白和装载机一直在旋转,并且 chrome 开发工具显示Failed to load resource: net::ERR_QUIC_PROTOCOL_ERROR.QUIC_PACKET_READ_ERROR

标签: google-analyticsgoogle-analytics-api

解决方案


重定向到https://console.developers.google.com/apis/api/analyticsreporting.googleapis.com并使用您创建了 client_id 和 client_secret 的 google 帐户登录,确保您在与客户端相同的项目中id 和 secrets 用于其他明智的更改项目。如果您没有访问权限,请让管理员执行相同操作

单击启用按钮,如下图所示 在此处输入图像描述

然后尝试做你的工作。它应该可以正常工作


推荐阅读