【发布时间】:2023-12-25 16:46:01
【问题描述】:
我是 Google API 的新手,几天来我一直在尝试使用服务帐户将内容上传到 Google Cloud Storage 存储桶。我能够做到这一点,但只能使用从 Google API 游乐场获得的临时访问令牌,并且我需要能够获取新的访问令牌,以便服务帐户始终可以上传内容。
我一直在尝试以下方法,但我一直被拒绝访问,即使相关帐户具有“所有者”权限。
curl -X POST / -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \ -H "Content-Type: application/json; charset=utf-8" \ -d @Documents/request.json \ https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/content-uploader@kol-hatorah-kulah.iam.gserviceaccount.com:generateAccessToken
回复:
{ "error": { "code": 403, "message": "The caller does not have permission", "status": "PERMISSION_DENIED" } }
当我运行 gcloud config list 时,我得到了正确的项目,并且该帐户是我的工作电子邮件,也是 Google Cloud 中的所有者。
提前致谢!
【问题讨论】:
标签: google-cloud-platform google-cloud-firestore oauth-2.0 google-api google-cloud-storage