Centos Linux on vmware - gsutil is working but I am trying to download objects from google cloud storage using python code. Running below python code fails as I am behind a prox
The google-cloud python library doesn't have support for proxies. gsutil's proxy support comes from its use of the boto library, so you might consider using that library if you need proxy support.
Although, google-cloud python library does not have support for proxies directly, it honors HTTPS_PROXY environment variable if set.
Either:
export HTTPS_PROXY=https://mycustomproxy.example.com:12345
python your_python_script.py
Or:
export https_proxy=https://mycustomproxy.example.com:12345
python your_python_script.py
You could also set this directly within your python script too (preferably at the very beginning):
import os
os.environ['https_proxy'] = 'https://mycustomproxy.example.com:12345'
from google.cloud import storage
storage_client = storage.Client()
bucket = storage_client.get_bucket('my-bucket')
blobs=bucket.list_blobs()
BTW, https_proxy is supported in the urllib module and hence any libraries (like google-cloud here) using urllib can transparently use the proxies for the requests.