Proxy (Serwer proxy)
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Jeśli chcesz połączyć się z interfejsem Google Ads API za pomocą serwera proxy, możesz to zrobić, ustawiając http_proxy
w pliku google-ads.yaml
:
# Proxy configuration
###############################################################################
# Below you can specify an optional proxy configuration to be used by #
# requests. If you don't have username and password, just specify host and #
# port. #
# #############################################################################
http_proxy: INSERT_PROXY_HERE
Możesz na przykład określić http://user:pass@localhost:8082
jako serwer proxy.
Możesz też skonfigurować ustawienie serwera proxy programowo za pomocą metod GoogleAdsClient
: load_from_dict
, load_from_env
i load_from_string
, tak jak w przypadku innych ustawień konfiguracji. Na przykład:
config = {
...
"http_proxy": "INSERT_PROXY_HERE",
}
googleads_client = GoogleAdsClient.load_from_dict(config)
Aby użyć serwera proxy z metodą load_from_env
, ustaw zmienną środowiskową GOOGLE_ADS_HTTP_PROXY
.
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-08-27 UTC.
[null,null,["Ostatnia aktualizacja: 2025-08-27 UTC."],[[["\u003cp\u003eConnect to the Google Ads API through a proxy by setting the \u003ccode\u003ehttp_proxy\u003c/code\u003e configuration in your \u003ccode\u003egoogle-ads.yaml\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eAlternatively, configure the proxy programmatically using \u003ccode\u003eGoogleAdsClient\u003c/code\u003e methods like \u003ccode\u003eload_from_dict\u003c/code\u003e, accepting a dictionary with an \u003ccode\u003ehttp_proxy\u003c/code\u003e key.\u003c/p\u003e\n"],["\u003cp\u003eTo use a proxy with the \u003ccode\u003eload_from_env\u003c/code\u003e method, set the \u003ccode\u003eGOOGLE_ADS_HTTP_PROXY\u003c/code\u003e environment variable.\u003c/p\u003e\n"]]],[],null,["# Proxy\n\nIf you need to connect to the Google Ads API through a proxy, you can do so by setting\nthe `http_proxy` config in your\n[`google-ads.yaml`](https://github.com/googleads/google-ads-python/blob/HEAD/google-ads.yaml)\nfile: \n\n # Proxy configuration\n ###############################################################################\n # Below you can specify an optional proxy configuration to be used by #\n # requests. If you don't have username and password, just specify host and #\n # port. #\n # #############################################################################\n http_proxy: INSERT_PROXY_HERE\n\nFor example, you can specify `http://user:pass@localhost:8082` as a proxy.\nAlternatively, you can configure the proxy setting programmatically using the\n`GoogleAdsClient` methods: `load_from_dict`, `load_from_env`, and\n`load_from_string`, just like any other configuration setting. For example: \n\n config = {\n ...\n \"http_proxy\": \"INSERT_PROXY_HERE\",\n }\n googleads_client = GoogleAdsClient.load_from_dict(config)\n\nTo use a proxy with the `load_from_env` method, set the `GOOGLE_ADS_HTTP_PROXY`\nenvironment variable."]]