gsutil是否支持使用服务帐户信息创建boto文件?

时间:2016-05-01 12:05:59

标签: google-cloud-storage boto google-cloud-platform service-accounts

根据几个示例,gsutil config可用于从服务帐户的OAuth2凭据创建与GCS兼容的.boto文件。

例如,https://cloud.google.com/storage/docs/xml-api/gspythonlibrary根据服务帐户凭据建议您应使用heidht配置.boto文件;但是,在运行该命令时,我得到:

gsutil config -e

按照说明,我尝试使用gcloud auth activate-service-account:

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".

但这不会创建.boto文件。

我可以在互操作性模式下配置可互操作的HMAC项目ID /秘密并使用它,但由于首选OAuth2凭据,并且服务帐户凭据似乎是正确的方法,我不知道如何继续。如何为服务帐户编写.boto文件?

$ 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]

1 个答案:

答案 0 :(得分:4)

gcloud将凭据存储在〜/ .config / gcloud(而不是.boto)下的文件中,然后在使用gsutil时将它们传递给gsutil。