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

Google Group Settings API授权错误排查求助

Google Group Settings API授权错误排查求助

各位大佬好!我最近在配置Group Settings服务时,卡在授权环节了,怎么都找不到问题所在。下面是我用来测试的代码,麻烦帮忙看看哪里出问题了?

import os
import internal_package
from google.oauth2 import service_account
from googleapiclient.discovery import build

# 从Vault读取凭证
gsuite_service_account = internal_package.vault.get_credential(service_account="gsuite_script", json_response=True)
if gsuite_service_account is None:
    raise ValueError('gsuite_script')
user_account = gsuite_service_account['user_email']

scopes = ['https://www.googleapis.com/auth/apps.groups.settings']

# 加载服务账号凭证
service_account_file = os.environ["GOOGLE_APPLICATION_CREDENTIALS"]

credentials = service_account.Credentials.from_service_account_file(service_account_file, scopes=scopes, subject=user_account)

group_client = build("groupssettings", "v1", credentials=credentials)
print("GSuite service successfully initialized")

目前我已经通过Vault获取了服务账号的凭证,指定了对应的用户邮箱作为subject,也添加了Group Settings需要的权限范围,但还是碰到授权相关的错误。有没有大佬能指点下可能的排查方向?比如是不是服务账号的全域委派(Domain-Wide Delegation)没配置对?或者凭证加载的环节有没有什么容易忽略的细节?

备注:内容来源于stack exchange,提问作者Vik

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.16 07:48:03