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?