Repository navigation
Partial proxy for GoogleAdsClient #831
Description
Activity
- addedquestionFurther information is requestedFurther information is requested
on May 20, 2025 It'd be helpful to understand the goal of your proxying approach, such as which call(s) you want to proxy. For example, do you want to proxy the service clients returned by
googleAdsClient.getLatestVersion().createXyzServiceClient()or something else?Thanks,
Josh, Google Ads API TeamYes, I am trying to proxy the service client returned by googleAdsClient. I basically want to route calls through my company's proxy server and I believe I'll have to proxy on the service clients for that. Please let me know if that is the right approach.
Thanks for clarifying. Would using setEndpoint(...) when building the
GoogleAdsClientwork?I tried setEndpoint("proxyHost:proxyPort") and also setEndpoint("proxyHost/googleads.googleapis.com:443") but it didn't work.
Got it. I just remembered: you should be able to use the standard Java system properties. For example:
-Dhttps.proxyHost=YOUR_PROXY_POST -Dhttps.proxyPort=YOUR_PROXY_PORTPlease give that a try and let us know how it goes.
Thanks
I am already using System.setProperty() to set the proxy and it is working fine. But I don't want to set proxy for all calls as different services in my application will use different proxies.How can I set proxy only for GoogleAdsClient?
You would need to use the 2nd or 3rd option described in grpc/grpc-java#9057 (comment).
For example, you could call the static method
ProxySelector.setDefault(yourProxySelector), whereyourProxySelectoris aProxySelectorsubclass that implements theselectmethod to determine which proxy to use for a given URI. See https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/net/ProxySelector.html.
I want to use partial proxy for GoogleAdsClient but cannot find any way to do so. Can someone suggest a way or a workaround for the same. The proxy I want to use does not require authentication, I just need to set the proxy before calling the search stream service.