הגדרת שרת Proxy

אם אתם צריכים להתחבר ל-Google Ads API דרך Proxy ל-HTTP או HTTPS, אתם יכולים להגדיר את http_proxy בקובץ התצורה, באופן פרוגרמטי או באמצעות משתנה סביבה. ההגדרה http_proxy חלה על ערוץ התעבורה הבסיסי של gRPC שמשמש את ספריית הלקוח של Python.

הגדרה באמצעות google-ads.yaml

מציינים את ההגדרה http_proxy בקובץ google-ads.yaml:

# Optional proxy configuration used for API requests. If your proxy does not
# require authentication, specify only the host and port.
http_proxy: INSERT_PROXY_HERE

לדוגמה, אפשר לציין את http://user:pass@localhost:8082 כשרת proxy.

הגדרה פרוגרמטית

אפשר גם להגדיר את הגדרות לשרת proxy באופן פרוגרמטי באמצעות שיטות האתחול של GoogleAdsClient (load_from_dict,‏ load_from_env ו-load_from_string), בדיוק כמו כל הגדרת תצורה אחרת:

from google.ads.googleads.client import GoogleAdsClient

config = {
    # Include other required configuration settings here.
    "http_proxy": "INSERT_PROXY_HERE",
}
googleads_client = GoogleAdsClient.load_from_dict(config)

הגדרה באמצעות משתני סביבה

כדי להגדיר שרת proxy באמצעות השיטה load_from_env, מגדירים את משתנה הסביבה GOOGLE_ADS_HTTP_PROXY:

export GOOGLE_ADS_HTTP_PROXY="http://user:pass@localhost:8082"