【发布时间】:2018-01-17 16:30:07
【问题描述】:
我正在查看位于以下位置的 API 参考:
https://googlecloudplatform.github.io/google-cloud-python/latest/storage/client.html
在使用服务帐户时,我应该如何进行身份验证?我看不到如何创建必要的Credentials 对象。
【问题讨论】:
标签: python google-cloud-storage
我正在查看位于以下位置的 API 参考:
https://googlecloudplatform.github.io/google-cloud-python/latest/storage/client.html
在使用服务帐户时,我应该如何进行身份验证?我看不到如何创建必要的Credentials 对象。
【问题讨论】:
标签: python google-cloud-storage
https://google-auth.readthedocs.io/en/stable/user-guide.html#service-account-private-key-files
from google.oauth2 import service_account
credentials = service_account.Credentials.from_service_account_file(
'/path/to/key.json')
scoped_credentials = credentials.with_scopes(
['https://www.googleapis.com/auth/cloud-platform'])
【讨论】: