4

I'm trying to use a WMS service that requires a subscription key be appended to all requests that are made to it.

I can sort of make it work by using http://machine.com/mappingserver?subscription-key=my-secret-key? as the base URL when adding the WMS. But this fails by default unless I remember to tick the Ignore GetMap/GetTile URL in capabilities boxes - then I get a map and can do identify but I can't see the legend that was carefully designed to help me understand the map.

Now, I can add an authentication configuration to my WMS service when I add it to QGIS, but none of the options seem to help me just specify a key and token that need to be added to any request. I thought I could fool the ESRI token store into doing this but it doesn't seem to want to help me out.

So, I guess my question boils down to am I missing something obvious or should I start reading the authentication code over the weekend?

4
  • as I am sure you know, if you're using the authkey module with GeoServer, the GetCapabilities call will automatically append the supplied authkey to the URLs that it returns, so QGIS just works beautifully with GeoServer and authkey. So you must be wanting a solution for a different mapping server? Your Ignore GetMap/GetTile URL in capabilities solution works best for me in this case. docs.geoserver.org/stable/en/user/community/authkey/index.html
    – PeterS
    Commented Jan 14, 2021 at 15:24
  • wchich version of QGIS do you use? in my version the ignore option includes the get legend uri ("Ignore GetMap/GetTile/GetLegendGraphic URI reported in capabilities")
    – Thomas B
    Commented Aug 30, 2023 at 13:12
  • It does indeed because I wrote a patch for that some time ago - I don't want to be telling users to have to remember to tick those boxes though
    – Ian Turton
    Commented Aug 30, 2023 at 13:20
  • Hey @IanTurton I am trying to do exactly the same and haven't found an alternative yet except telling users to tick the boxes. Any luck for you?
    – d.lime
    Commented Oct 31 at 1:33

2 Answers 2

3

Not sure how new this feature is, but you can specify keys and values to be appended to requests, when creating the connection in QGIS, under HTTP Headers > Advanced (like @Bernd Loigge suggested):

QGIS create WMS Connection window

2

The token needs to be provided on every xlink:href attribute in the Capabilities document like LegendURL. If the parameter is provided correctly QGIS will have no issue displaying the legend. So I don't think this is something QGIS needs to deal with rather the server needs to provide the correct URLs already with the token appended.

3
  • probably, but I'm trying to talk to servers in the wild that I have no control over
    – Ian Turton
    Commented Aug 30, 2023 at 10:34
  • 1
    If the server is out of your hand I guess having something similar to the HTTP Headers options like a key / value list for extra parameters which are always appended to every sub-request of a WMS source would be good to have. Commented Aug 30, 2023 at 12:50
  • If the server isn't yours, you could create a static capabilities document (with appropriate edits) and put on your own webserver, then point QGIS to that file.
    – nmtoken
    Commented May 31 at 11:15

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.