<div dir="ltr"><div>The proxy settings are only set up for core class in QGIS, which you should look at to make your requests.</div><div>CF <a href="https://gis.stackexchange.com/questions/343126/how-to-perform-sync-or-async-network-request-in-pyqgis">https://gis.stackexchange.com/questions/343126/how-to-perform-sync-or-async-network-request-in-pyqgis</a></div><div><br></div><div>If you really want to use "requests", you should read the QgsSettings about proxy and use these values in requests as well.</div><div>Similar to <a href="https://stackoverflow.com/questions/23041066/setting-proxy-parameter-in-qgis-plugins-how-to/37757921#37757921">https://stackoverflow.com/questions/23041066/setting-proxy-parameter-in-qgis-plugins-how-to/37757921#37757921</a></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le jeu. 21 janv. 2021 à 15:03, Sampo Savolainen <<a href="mailto:sampo.savolainen@spatineo.com">sampo.savolainen@spatineo.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I'm developing a small QGIS plugin (<a href="https://github.com/spatineo/qgis-intelligent-search/" target="_blank">https://github.com/spatineo/qgis-intelligent-search/</a>) and ran into issues with proxy configuration. The plugin uses the Python requests library to make HTTP API calls and owslib to download and parse GetCapabilities documents from WxS services. Owslib seems to use the same requests library to make HTTP calls. However proxies are (unsurprisingly) giving us headaches.</div><div><br></div><div>We have tested the plugin in two environments where proxies are required to make HTTP requests. The environments had different versions of QGIS: 3.14 and 3.10, both in Windows. The first environment (newer version) is able to make the API calls using the requests library, but owslib fails to connect to services.  The older version of QGIS fails to connect to the API and the owslib part never gets tested. Note that this discrepancy may be related to the API being available without a proxy in the first environment  - though this is just a suspicion, I have been unable to confirm this.

</div><div><br></div><div>With 3.10, I've tried QGIS proxy configuration both as "DefaultProxy" (use system config) and as "HttpProxy" but neither one helped. However I was able to make it work by setting the http_proxy and https_proxy environment variables in a shell and launching QGIS from that shell.</div><div><br></div><div>So this seems to boil down to the QGIS proxy settings are not passed to the plugin via http_proxy and https_proxy environment variables. Is there a best practice on how plugins should access proxy configuration in QGIS and use it?</div><div><br></div><div><br></div><div> Thanks,</div><div> Sampo</div><div><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><font face="arial, sans-serif"><div><div style="font-size:12.8px"><span style="color:rgb(153,153,153);font-size:small">Sampo Savolainen</span><br></div><div style="font-size:12.8px"><font color="#999999"><span style="font-size:small">Managing Director</span><br></font></div><div><font color="#999999">Työpajankatu 9 D, 00580 Helsinki, Finland</font><br></div><div style="font-size:12.8px"><div style="font-size:12.8px"><div dir="ltr"><font size="2" color="#999999"><a href="http://www.spatineo.com/" target="_blank">www.spatineo.com</a><br>Tel. +358 40 7555 649</font></div></div><div style="color:rgb(136,136,136);font-size:12.8px"><div style="color:rgb(0,0,0);font-size:small"><br></div></div></div><div dir="ltr" style="color:rgb(136,136,136);font-size:12.8px"></div></div><div dir="ltr" style="color:rgb(136,136,136);font-size:12.8px"><img src="http://directory.spatineo.com/img/spatineo.gif" width="200" height="39"><br></div><div dir="ltr" style="color:rgb(136,136,136);font-size:12.8px"><br></div><div dir="ltr"><font size="1" color="#999999">This message may contain privileged and/or confidential information. If you have received this e-mail in error or are not the intended recipient, you may not use, copy, disseminate, or distribute it; do not open any attachments, delete it immediately from your system and notify the sender promptly by e-mail that you have done so.</font></div></font></div></div></div></div></div></div></div></div></div></div></div>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div>