[Qgis-user] Reading Credentials from Authentification Configuration

Fuenfer-Koenigstein.Benjamin at swm.de Fuenfer-Koenigstein.Benjamin at swm.de
Wed Feb 13 06:58:35 PST 2019


Hi,

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
s = QSettings()
proxy_user = s.value("proxy/proxyUser","")
proxy_password = s.value("proxy/proxyPassword","")

But I have problems to do this with proxy settings with authentification configuration. What I got so far is:

a = QgsApplication.authManager()
auth_config = s.value("proxy/authcfg","")
meth = a.availableAuthMethodConfigs()[auth_config]
print(meth.name())

returns the name of auth config I set for proxy, but I cant read credentials from the auth config:

print(meth.hasConfig('username'),meth.hasConfig('password'))

returns
False False

Do I use wrong keys for credentials? Do I have to prompt master password for auth db to be able to read config?

print(a.masterPasswordIsSet(), a.masterPasswordSame('mymasterpassword'))
returns
            True True


Thanks for any help!

Regards
Benjamin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20190213/fd5bdb5c/attachment.html>


More information about the Qgis-user mailing list