【发布时间】:2016-08-26 06:34:58
【问题描述】:
根据几个示例,gsutil config 可用于从服务帐户的 OAuth2 凭据创建与 GCS 兼容的 .boto 文件。
例如,https://cloud.google.com/storage/docs/xml-api/gspythonlibrary 在服务帐户凭据下建议您应该使用 gsutil config -e 配置 .boto 文件;但是,在运行该命令时,我得到:
CommandException: OAuth2 is the preferred authentication mechanism
with the Cloud SDK. Run "gcloud auth login" to configure authentication,
unless you want to authenticate with an HMAC access key and secret,
in which case run "gsutil config -a".
按照说明,我尝试使用 gcloud auth activate-service-account:
$ gcloud auth activate-service-account --key-file=/Users/crschmidt/mirandum-local/cloud-storage-service.json
Activated service account credentials for: [gcs-storage@livestream-alerts.iam.gserviceaccount.com]
但这不会创建 .boto 文件。
我可以在互操作模式下配置一个可互操作的 HMAC 项目 ID/秘密并使用它,但由于首选 OAuth2 凭据,并且服务帐户凭据似乎是正确的方法,我不确定如何继续。如何为服务帐户编写 .boto 文件?
crschmidt-macbookair:~ crschmidt$ gsutil --version
gsutil version: 4.19
【问题讨论】:
-
gcloud 的更新版本有一个更好的错误消息,说您需要更改
gcloud config set pass_credentials_to_gsutil false然后运行命令帐户。我已经这样做了,它生成了 .boto 文件。
标签: google-cloud-storage boto google-cloud-platform service-accounts