Skip to content

Partial proxy for GoogleAdsClient #831

Description

@rawatnikita

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.

Activity

  1. jradcliff commented on May 20, 2025

    @jradcliff
    Member

    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 Team

  2. rawatnikita commented on May 20, 2025

    @rawatnikita
    Author

    Yes, 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.

  3. jradcliff commented on May 20, 2025

    @jradcliff
    Member

    Thanks for clarifying. Would using setEndpoint(...) when building the GoogleAdsClient work?

  4. self-assigned this
    on May 20, 2025
  5. rawatnikita commented on May 20, 2025

    @rawatnikita
    Author

    I tried setEndpoint("proxyHost:proxyPort") and also setEndpoint("proxyHost/googleads.googleapis.com:443") but it didn't work.

  6. jradcliff commented on May 20, 2025

    @jradcliff
    Member

    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_PORT

    Please give that a try and let us know how it goes.

    Thanks

  7. rawatnikita commented on May 20, 2025

    @rawatnikita
    Author

    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?

  8. jradcliff commented on May 20, 2025

    @jradcliff
    Member

    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), where yourProxySelector is a ProxySelector subclass that implements the select method 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions