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

EarthDataDownloader object to retain user login credentials #200

Closed
PennyHow opened this issue Apr 24, 2024 · 6 comments · Fixed by #216
Closed

EarthDataDownloader object to retain user login credentials #200

PennyHow opened this issue Apr 24, 2024 · 6 comments · Fixed by #216

Comments

@PennyHow
Copy link
Contributor

Description of the desired feature: Functionality added so that login credentials are retained by the EarthDataDownloader object after first inputted, and therefore the user does not have to keep re-defining them for each download.

In the tutorials, there is repeated EarthData login requests. For example, in the 3D_stack tutorial:

measures_shelves = fetch.measures_boundaries(version="IceShelf")

Also, there is nothing in your documentation on how to define credentials as environment variables (the icepack link in the API reference for EarthDataDownloader is broken).

@JessicaS11
Copy link

If you're not familiar with it, I strongly recommend earthaccess. It's a great way to manage Earthdata logins. The library I maintain, icepyx has it set up as an authentication MixIn class so the credentials are accessible from any module that needs them but only asks users for them once.

@mdtanker
Copy link
Owner

Thanks for the suggestions! I had a look, but I'm not sure if this will work here. polartoolkit uses pooch to download the datasets. For the NASA data, pooch requires the earthdata username and password to be entered into the download call. Looking through earthaccess, I couldn't see a way to return the username and password values to pass to pooch. Maybe I missed it, is there a way to do this?

For now, I've kept it as is, but added better documentation for how to set temporarily or permanent environment variables so users don't need to continuously supply the login credentials.

@PennyHow
Copy link
Contributor Author

For now, I've kept it as is, but added better documentation for how to set temporarily or permanent environment variables so users don't need to continuously supply the login credentials.

I think as long as it is well documented then this is enough to resolve the issue

@mdtanker
Copy link
Owner

Ok that sounds good to me, I'll close this as I've added better documentation in #212 in this how-to guide.

@JessicaS11
Copy link

Looking through earthaccess, I couldn't see a way to return the username and password values to pass to pooch. Maybe I missed it, is there a way to do this?

It's not part of the user api (and probably not documented), but with an earthaccess Auth object (created with myauth = earthaccess.login()) you should be able to get them with myauth.auth_environ() (or possibly myauth.auth.auth_environ()).

As @PennyHow noted - not required for JOSS, but wanted to follow up and answer your question!

@mdtanker
Copy link
Owner

Ahh great! Thanks for finding that, this is working to access the credentials: earthaccess.auth_environ().

I'll add this into PolarToolkit to replace the custom class I had.

@mdtanker mdtanker reopened this Jun 22, 2024
@mdtanker mdtanker linked a pull request Jul 12, 2024 that will close this issue
Merged
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 a pull request may close this issue.

3 participants