我正在查看位于以下位置的API参考:
https://googlecloudplatform.github.io/google-cloud-python/latest/storage/client.html
在使用服务帐户时,我打算如何进行身份验证?我不知道如何创建必要的Credentials
对象。
答案 0 :(得分:0)
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'])