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
相关产品推荐
相关产品推荐

