Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include custom headers in WMS requests #763

Merged
merged 2 commits into from Jun 3, 2021

Conversation

amercader
Copy link
Contributor

I recently needed to interact with a WMS service which require authentication via a User-agent header (from France's IGN).

When using WebMapService you can actually provide custom headers but they are not used later on when doing the actual HTTP requests:

wms = WebMapService(
    'http://example.com/wms',
    version='1.3.0',
    headers={'User-agent': 'my-app/1.0'}
)

wms.getmap(...)  # Fails as not authorized

The openURL() helper already supports sending headers if provided, so it was just a matter of adding the WMS client instance headers (if present) to this function call.

Includes a small test.

I recently needed to interact with a WMS service which require
authentication via a `User-agent` header (from France IGN [1]).

When using `WebMapService` you can actually provide custom headers but
they are not used later on when doing the actual HTTP requests:

    wms = WebMapService(
        'http://example.com/wms',
        version='1.3.0',
        headers={'User-agent': 'my-app/1.0'}
    )

    wms.getmap(...)  # Fails as not authorized

The `openURL()` helper already supports sending headers if provided, so
it was just a matter of adding the WMS client instance headers (if present) to
this function call.

Includes a small test.

[1] https://geoservices.ign.fr/documentation/donnees-ressources-wms-geoportail.html
@amercader
Copy link
Contributor Author

I get the same failure (tests/test_ogcapi_features_pygeoapi.py::test_ogcapi_features_pygeoapi FAILED) with latest master so not sure if it's related

@amercader amercader mentioned this pull request Mar 5, 2021
10 tasks
amercader added a commit to amercader/munibot that referenced this pull request Mar 29, 2021
Don't pass styles by default, pass headers if provided.

This requires a patch in OWSLib to work:

geopython/OWSLib#763
@tomkralidis tomkralidis merged commit dc9a22f into geopython:master Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants