1

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?

2
  • 1
    Look at tests e.g github.com/qgis/QGIS/blob/master/tests/src/python/… It should give you the missing clues
    – ThomasG77
    Commented Oct 28, 2021 at 0:44
  • Thank you, @ThomasG77. 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. Commented Oct 28, 2021 at 11:14

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.