# ObsPy FDSNWS client and HTTP Basic Authentication

**URL:** <https://discourse.obspy.org/t/obspy-fdsnws-client-and-http-basic-authentication/638>\
**Category:** Users Mailing List Archive\
**Tags:** archive\
**Created:** [April 20, 2017, 2:28pm UTC](https://discourse.obspy.org/t/obspy-fdsnws-client-and-http-basic-authentication/638 "2017-04-20T14:28:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fabian\_Euchner](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/f/a88e57/32.png) [@Fabian\_Euchner](https://discourse.obspy.org/u/Fabian_Euchner)\
**Post date:** [April 20, 2017, 2:28pm UTC](https://discourse.obspy.org/t/obspy-fdsnws-client-and-http-basic-authentication/638/1 "2017-04-20T14:28:49Z")

</div>

Hi all,

is there a way to use the FDSNWS client to consume fdsnws-dataselect services that are hidden behind HTTP basic authentication? The user and password arguments seem only to work with the Digest Authentication and the /queryauth method as described in the standard. I have a use case in which /queryauth would be overkill, the service should just not be accessible without credentials. No problem to consume this via curl/wget, but it would be nice to be able to use the ObsPy client.

Regards,

Fabian

---

<div class="post-metadata">

**Author:** ![Chad\_Trabant](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/c/bcef8e/32.png) [@Chad\_Trabant](https://discourse.obspy.org/u/Chad_Trabant)\
**Post date:** [April 20, 2017, 4:11pm UTC](https://discourse.obspy.org/t/obspy-fdsnws-client-and-http-basic-authentication/638/2 "2017-04-20T16:11:24Z")

</div>

Hi Fabian,

Out of curiosity can you describe why you believe /queryauth with HTTP Digest Authentication is overkill compared to HTTP Basic Authentication? Most HTTP frameworks, client and server, support both with about the same amount of complexity.

thanks,  
Chad

---

<div class="post-metadata">

**Author:** ![Fabian\_Euchner](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/f/a88e57/32.png) [@Fabian\_Euchner](https://discourse.obspy.org/u/Fabian_Euchner)\
**Post date:** [April 21, 2017, 8:52am UTC](https://discourse.obspy.org/t/obspy-fdsnws-client-and-http-basic-authentication/638/3 "2017-04-21T08:52:42Z")

</div>

Hi Chad,

(this is getting slightly off-topic on the obspy-users list, sorry for that…)

> Out of curiosity can you describe why you believe /queryauth with HTTP

> Digest Authentication is overkill compared to HTTP Basic Authentication?

> Most HTTP frameworks, client and server, support both with about the same

> amount of complexity.

My problem is not with Digest Authentication per se. Configuring /queryauth in the SeisComP3 implementation of fdsnws-dataselect just adds some complexity which I would like to avoid. I don’t need fine-grained access permissions per user, I just need a general “open sesame”.

Cheers,

Fabian

---

<div class="post-metadata">

**Author:** ![LionKrischer](https://discourse.obspy.org/user_avatar/discourse.obspy.org/lionkrischer/32/219_2.png) [@LionKrischer](https://discourse.obspy.org/u/LionKrischer)\
**Post date:** [April 25, 2017, 6:16am UTC](https://discourse.obspy.org/t/obspy-fdsnws-client-and-http-basic-authentication/638/4 "2017-04-25T06:16:37Z")

</div>

Hi Fabian,

currently not as its not defined in the standard.

But you could subclass the Client and manually add an HTTPBasicAuthHandler, e.g. (untested and Py3 only):

class MyClient(Client):

def **init** (self, \*args, \*\*kwargs):

super(). **init** (\*args, \*\*kwargs)

handlers = password\_mgr = urllib\_request.HTTPPasswordMgrWithDefaultRealm() password\_mgr.add\_password(None, base\_url, user, password) handlers.append(urllib\_request.HTTPBasicAuthHandler(password\_mgr)) # Don’t install globally to not mess with other codes. self.\_url\_opener = urllib\_request.build\_opener(\*handlers)

Cheers!

Lion
