无法在python中验证Google Cloud Storage客户端 [英] Unable to authenticate Google Cloud Storage client in python
本文介绍了无法在python中验证Google Cloud Storage客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用以下代码访问Google云存储:
I'm trying the following code to access the Google Cloud storage:
client = storage.Client(credentials = GoogleCredentials.from_stream(<path-to-service-account-json>))
引发此错误:
ValueError: This library only supports credentials from google-auth-library-python. See https://google-cloud-python.readthedocs.io/en/latest/google-cloud-auth.html for help on authentication with this library.
我能够使用相同的凭据(使用GoogleCredentials.from_stream()
获取)对discovery.build
服务进行身份验证,但是出于某种原因存储.客户端无法使用提供的凭据.
I'm able to authenticate discovery.build
service using the same credentials(obtained using GoogleCredentials.from_stream()
), but for some reason storage.Client fails to use the provided credentials.
请让我知道我是否缺少任何东西.
Please let me know if I'm missing something.
推荐答案
使其与以下代码一起使用:
Got it to work with the following code:
storage_client = storage.Client.from_service_account_json(<path-to-service-account-json>)
不确定为什么要使用不同的方法来验证发现API以及存储和其他客户端API.
Not sure why there are different way to authenticate the discovery API and the storage and other client APIs.
这篇关于无法在python中验证Google Cloud Storage客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文