Python Script node: Proxy authentication issues

Hi

I’ve got a Python Script node that scrapes a data table from a website. I access the web from behind a corporate firewall that requires proxy authentication. I’ve got Knime Analytics installed on my Windows 10 machine. When I set it’s proxy as “Native” under preferences, Knime can look for -and download- updates etc. But for some reason I can’t get the python code to connect even if I set the request proxies parameter:
r = requests.get(url, proxies={‘http’:‘http://company.proxy.com:port’})

If I set Knime’s Proxy settings to “Manual” and specify the proxy details there, Knime will prompt me for my proxy username and password upon startup and then the Python script executes fine.

Is there a way to get the python script to use the Windows current user credentials to do the proxy authentication just like Knime does when using “Native” proxy configuration?

I finally figured out a way. The PyPac python module will auto-discover Windows proxy settings and do the proxy authentication pass-through as well:

from pypac import PACSession
session = PACSession()
html = session.get(‘http://google.com’).text

Now you don’t need to worry about any proxy settings in the Python Script node anymore.

3 Likes

Hi @koeties,

thanks for that valid workaround! We also have a ticket to let the Python script node use the KNIME proxy settings (AP-22294) and will come back once we implemented that.

Best regards
Steffen

1 Like

Thanks for the feedback @steffen_KNIME.

Another question (maybe for another thread?) is that when I set my Knime proxy settings to “Native”, I can’t connect to the Knime Hub from within Knime. But as soon as I change it to manual and specify proxy details, I can connect. Maybe another thing to look into?

Hi @koeties,

this bug is known and should be fixed in 5.2.3 and 5.3

Best regards
Steffen

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.