Giter Site home page Giter Site logo

Comments (5)

msaniscalchi avatar msaniscalchi commented on June 23, 2024

Hello,

I strongly suspect the core issue here is that you're defining the proxy outside of the library. As currently implemented, we use ProxyConfig to pass the proxy details along to Zeep. This can be configured in googleads.yaml, or passed along as an argument for AdManagerClient if you prefer to set it up manually.

Regards,
Mark

from googleads-python-lib.

hein3r avatar hein3r commented on June 23, 2024

Hi Mark,

thanks for the quick reply.

I doubt that this is the case (maybe my hint about requests was misleading, because I do not use this in the current Google Ads project).

I do specify the proxy in the googleads.yaml like so:

proxy_config:
    'http': 'http://[DOMAIN]%5C[USER]:[PWD]@[HOST]:8080'

This config is then used

from googleads import ad_manager
ad_manager_client = ad_manager.AdManagerClient.LoadFromStorage("googleads.yaml")
activity_service = ad_manager_client.GetService('ActivityService', version='v202402')

When I try to get the ActivityService for example, I get the 407.

from googleads-python-lib.

msaniscalchi avatar msaniscalchi commented on June 23, 2024

Hello,

Thanks for clarifying, I had in fact misinterpreted that original post, sorry about that!

So, I'll be upfront about it–it would be quite difficult for me to troubleshoot your specific proxy issue, but I can say that the fact you received an HTTP 407 response strongly suggests that the library passed along your proxy configuration to Zeep, which then made the request, and did at least communicate with your proxy so that it could return the authentication error. I'd like to at least provide some explanation on why this doesn't appear to be an issue with this library though, so read on if that interests you.

Looking at the underlying implementation, LoadFromStorage eventually extracts a ProxyConfig based on your proxy_config found in googleads.yaml. When you call GetService, that ProxyConfig is then passed to GetServiceClassForLibrary, which uses ZeepServiceProxy to initialize a transport with the ProxyConfig, which is used by Zeep's Client to handle communication. I can confirm that the proxy configuration is passed to Zeep and should be applied to its requests, so as far as this library is concerned it appears to be working as intended.

For some additional context, the transport created above is a _ZeepProxyTransport, which applies the proxies to the Session used by the Zeep Client to make requests. As an example, for the GetService call, Zeep eventually calls the transport's _load_remote_data, where the following is used to retrieve the WSDL:

        response = self.session.get(url, timeout=self.load_timeout)

Once again, I can confirm that the proxy configuration is applied to the session used to make the call, so it appears to be working as intended.

from googleads-python-lib.

hein3r avatar hein3r commented on June 23, 2024

Hi Marc,
thank you for this extensive explanation. With that I was able to resolve the issue.
Figuring out that request does in fact handle Zeep's transport, I worked up a minimal example for a proxied session. As it turned out, request was ignoring the explicitly configured proxy in favor of a environment varible that was still set and I didn't know about. Removing that env var (either by session.trust_env=False or manually) the proxy config was then recognized correctly.
Thanks again and best regards

from googleads-python-lib.

msaniscalchi avatar msaniscalchi commented on June 23, 2024

Great, happy to hear you were able to figure it out!

from googleads-python-lib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.