-
Notifications
You must be signed in to change notification settings - Fork 529
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
Support for .netrc
files for authentication?
#3426
Comments
I don't see why we shouldn't add support for that. It might be a little bit more complicated to add though, when you look at where authentication is handled, probably adding to the password manager or something, didn't look into all the details: obspy/obspy/clients/fdsn/client.py Lines 341 to 360 in 3ae0030
Also, we would definitely want to use In [2]: urllib.parse.urlparse('http://service.iris.edu')
Out[2]: ParseResult(scheme='http', netloc='service.iris.edu', path='', params='', query='', fragment='') |
Ah, nice. Then that line in my example is: host = urlparse(base_url).netloc # Parse URL Noted on the possibly more complicated implementation details. I'll take a look at this when I have time... |
Problem
EarthScope (formerly IRIS) provides
.netrc
files for restricted data access. These have the formwhere
<user>
and<password>
are the arguments taken byobspy.clients.fdsn.client.Client
(hereafter,Client
). The.netrc
file can be conveniently downloaded from the SAGE Data Services account:It would be convenient if the
Client
checked for~/.netrc
in its__init__()
method and if an entry was present which matchedself.base_url
, it populateduser
andpassword
automatically. This would allow folks to avoid providinguser
andpassword
as arguments or via theset_credentials()
method — therefore, helping us avoid sticking such credentials in the code itself.Then we could ask EarthScope to update the text here 😉
Proposed solution
Here's a proof-of-concept snippet that could be adopted into the
__init__()
method to accomplish this. It uses thebase_url
attribute to determine which host to grab credentials for.We'd want to not overwrite the
user
andpassword
if they're provided to__init__()
(i.e., if they're notNone
) of course.The text was updated successfully, but these errors were encountered: