<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">do you mind to user QgsNetwrkAccessManager as described in<div><br></div><div><a href="https://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/authentication.html">https://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/authentication.html</a></div><div><br></div><div>or a way to usbstitute request with a wrapper to QgsNetwrkAccessManager as in:</div><div><a href="https://github.com/boundlessgeo/lib-qgis-commons/blob/master/qgiscommons2/network/networkaccessmanager.py">https://github.com/boundlessgeo/lib-qgis-commons/blob/master/qgiscommons2/network/networkaccessmanager.py</a></div><div><br></div><div>or using last api introduced by Nyall:</div><div><a href="https://github.com/qgis/QGIS/pull/8440">https://github.com/qgis/QGIS/pull/8440</a></div><div>and related follow-up</div><div><br></div><div>pyqgis coockbook should be updated to these new features</div><div><br clear="all"><div><div dir="ltr" class="gmail_signature">Luigi Pirelli<br><br>**************************************************************************************************<br>* LinkedIn: <a href="https://www.linkedin.com/in/luigipirelli" target="_blank">https://www.linkedin.com/in/luigipirelli</a><br>* Stackexchange: <a href="http://gis.stackexchange.com/users/19667/luigi-pirelli" target="_blank">http://gis.stackexchange.com/users/19667/luigi-pirelli</a><br>* GitHub: <a href="https://github.com/luipir" target="_blank">https://github.com/luipir</a><br>* Mastering QGIS 2nd Edition:<br>* <a href="https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition" target="_blank">https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition</a><br>* Hire me: <a href="http://goo.gl/BYRQKg" target="_blank">http://goo.gl/BYRQKg</a><br>**************************************************************************************************</div></div><br></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 13 Feb 2019 at 16:08, <<a href="mailto:Fuenfer-Koenigstein.Benjamin@swm.de">Fuenfer-Koenigstein.Benjamin@swm.de</a>> wrote:<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 lang="DE">
<div class="gmail-m_8428246168637964257WordSection1">
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext">Hi,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext">I use the OSM Tools plugin in QGIS3. It uses requests library for connecting to a OSM routing API. Unfortunately the plugin does not considder proxy settings set in Options->Network. I successfully
 implemented this for credentials set in the ‚Basic‘ section by <u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:11pt;color:windowtext">s = QSettings()<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:11pt;color:windowtext">proxy_user = s.value("proxy/proxyUser","")<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:11pt;color:windowtext">proxy_password = s.value("proxy/proxyPassword","")<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext">But I have problems to do this with proxy settings with authentification configuration. What I got so far is:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext"><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:11pt;color:windowtext">a = QgsApplication.authManager()<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:11pt;color:windowtext">auth_config = s.value("proxy/authcfg","")<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:11pt;color:windowtext">meth = a.availableAuthMethodConfigs()[auth_config]<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:11pt;color:windowtext">print(<a href="http://meth.name" target="_blank">meth.name</a>())<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext">returns the name of auth config I set for proxy, but I cant read credentials from the auth config:<u></u><u></u></span></p>
<p class="MsoNormal" style="text-indent:35.4pt"><span style="font-size:11pt;color:windowtext"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-indent:35.4pt"><span style="font-size:11pt;color:windowtext">print(meth.hasConfig('username'),meth.hasConfig('password'))<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext">returns <u></u>
<u></u></span></p>
<p class="MsoNormal" style="text-indent:35.4pt"><span style="font-size:11pt;color:windowtext">False False<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext">Do I use wrong keys for credentials? Do I have to prompt master password for auth db to be able to read config?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-indent:35.4pt"><span style="font-size:11pt;color:windowtext">print(a.masterPasswordIsSet(), a.masterPasswordSame('mymasterpassword'))<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext">returns<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext">            True True<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext">Thanks for any help!<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext">Regards <u></u>
<u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;color:windowtext">Benjamin<u></u><u></u></span></p>
</div>
</div>

_______________________________________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a></blockquote></div>