qgis – Troubleshooting Non-Standard WMS Parameters Not Sent in GetMap Requests via QGIS

parametersqgisSecuritywms

I am coding a python plugin to QGIS that connects to the UK National Biodiversity Network (NBN) Web Mapping Service (WMS). In general, I don't have any problems doing this with the QgsRasterLayer API when I want to access the WMS as a public user. The problem is when I want to access the WMS as a registered user (to get access to secured data).

The NBN WMS provides a method for doing this by supplying a username and an MD5 hashed password as additional parameters to the web service called username and userkey respectively (https://data.nbn.org.uk/Documentation/Web_Services/Web_Map_Services/).

The parameters work as advertised when requests are tested in a browser. However, they have no effect when used through QGIS and when I used Fiddler to examine the HTTP requests that QGIS is actually sending to the NBN WMS, I find that the username and userkey parameters are no sent by QGIS.

They are non-standard parameters, but the OGC standard says that non-standard parameters are allowed (and don't break the standard). Does anyone know why QGIS strips these non-standard parameters out of the HTTP request or how I can get around it?

Best Answer

As a workaround you can include extra parameters into the WMS server base URL. Remember also to check the "Ignore GetMap URI reported in capabilities". If username and userkey are changed you must edit the WMS connection details accordingly. Standard does not say either that WMS clients should keep the vendor parameters. Make a feature request for QGIS and suggest that there should be a box for vendor parameters. Ask to make it large so that also SLD_BODY fits into the box. Check first if such feature request exists already.

Related Question