QGIS – Fixing Plugin Proxy Credential Reading Issues from authcfg

PROXYpyqgisqgis

I'm developing a public python plugin for QGIS. To support QGIS proxy settings, I use Qt Network. The plugin sends HTTP requests via the QgsNetworkAccessManager's get/post/delete methods.

To test proxy support, I set up a proxy as below (with the real host & port of course):
Proxy setup

I enter the credentials into Basic Auth and click Convert to configuration. This creates a new config and erases the entered credentials from the Basic Auth tab's fields.
Next, I restart QGIS, check that the created config is selected in proxy settings, run my plugin, and get a credentials input dialog:
Credentials input dialog

When I enter the credentials, it works. It also works if I keep the credentials in the Basic Auth tab in QGIS proxy settings. But why doesn't my plugin read the configuration?

Best Answer

It turns out the only thing I had to do was call setupDefaultProxyAndCache() explicitly on the QgsNeworkAccessManager. It's a pity it's not explained anywhere in the docs. Although, I'd expect QGIS to execute this command automatically at startup.

Thanks to ThomasG77 for giving me a clue.