You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Python调用Google Analytics v4 API遇403权限不足问题求助

调用Google Analytics v4 API时遭遇403权限错误(服务账号场景)

错误详情

googleapiclient.errors.HttpError: <HttpError 403 when requesting https://analyticsreporting.googleapis.com/v4/reports:batchGet?alt=json returned "User does not have sufficient permissions for this profile.". Details: "User does not have sufficient permissions for this profile.">

场景说明

使用**服务账号(Service Account)**进行API调用

服务账号创建流程

  1. 进入Google Cloud Console;
  2. 创建仅用于该API的新项目;
  3. 启用Analytics Reporting API、Google Analytics Admin API、Google Analytics Data API和Google Analytics API;
  4. 进入Credentials页面创建新服务账号;
  5. 为其配置相应凭据;
  6. 在Domain-wide Delegation中添加作用域;
  7. 将服务账号邮箱(xxxxx@xxxxx.iam.gserviceaccount.com)添加为Google Analytics控制台管理员。

已尝试的解决方法

  1. 将服务账号邮箱添加为Analytics控制台管理员;
  2. 在Google Cloud的Domain-wide Delegation中添加作用域;
  3. 查阅Google官方文档;
  4. 更换其他拥有凭据的服务账号.json文件,仍无效;
  5. 遵循Google官方教程步骤操作,仍无效;
  6. 更换其他VIEW_ID,仍无效。

补充说明

Google API显示服务已初始化,但无法获取数据,返回403错误。已查阅StackOverflow相关问答,未找到有效解决方案。

内容的提问来源于stack exchange,提问作者ytpm

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 07:09:52