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

Common approach for .netrc authentication? #60

Open
scottyhq opened this issue Jun 27, 2022 · 3 comments
Open

Common approach for .netrc authentication? #60

scottyhq opened this issue Jun 27, 2022 · 3 comments

Comments

@scottyhq
Copy link
Member

I've noticed lots of tutorials each starting with a slightly different piece of code to check if there is a a valid .netrc, and if not, create one. This has led to errors in past hackweeks, where for example special characters aren't recognised, untested code creates (or overwrites) malformed ~/.netrcs, etc.

@egreckase (+ @betolink) would you recommend sticking with the earthdata library across tutorials for this critical step? Or adding a script that everyone can run on the jupyterhub (https://nasa-openscapes.github.io/2021-Cloud-Hackathon/tutorials/04_NASA_Earthdata_Authentication.html)?

Our current recommendation is here and could be revised https://snowex.hackweek.io/preliminary/earthdata.html#configure-programmatic-access-to-nasa-servers

@betolink
Copy link

betolink commented Jun 28, 2022

This is work in progress but for the next release we could use earthdata (internally uses tinynetrc). With earthdata we will be able to persist the credentials if they don't exist and the workflow would be simpler:

from earthdata import Auth

auth = Auth().login(strategy="netrc")
# are we authenticated?
if not auth.authenticated:
    # ask for credentials and persist them in a .netrc file
    auth.login(strategy="interactive", persist=True)

I'm thinking about writing some tests for password with special characters or currently malformed netrc files. This could also live in the earthdata documentation.

This was referenced Jun 29, 2022
@ZachHoppinen
Copy link
Member

ZachHoppinen commented Jun 30, 2022

Not sure if it would be helpful but pytool's create_netrc will either create the netrc with the username and password or add it to an existing netrc with the earth data login. It is adapted from the NASA git authentication script.

from uavsar_pytools.uavsar_tools import create_netrc
create_netrc() #will password safe prompt for username and password

@ZachHoppinen
Copy link
Member

scratch that I see that the earth data setup looks better.

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

No branches or pull requests

3 participants