Unable to authenticate Google Cloud Storage client in python

耗尽温柔 提交于 2020-05-29 06:20:17

问题


I'm trying the following code to access the Google Cloud storage:

client = storage.Client(credentials = GoogleCredentials.from_stream(<path-to-service-account-json>))

Throws this error:

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.

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.


回答1:


Got it to work with the following code:

storage_client = storage.Client.from_service_account_json(<path-to-service-account-json>)

Not sure why there are different way to authenticate the discovery API and the storage and other client APIs.



来源:https://stackoverflow.com/questions/45645717/unable-to-authenticate-google-cloud-storage-client-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!