"You must call earthaccess.login() before you can download data"

Use this Forum to find information on, or ask a question about, NASA Earth Science data.
Post Reply
ldove46
Posts: 2
Joined: Mon Dec 16, 2024 4:59 pm America/New_York
Answers: 0

"You must call earthaccess.login() before you can download data"

by ldove46 » Mon Dec 16, 2024 5:02 pm America/New_York

Hi all, I am trying to download SWOT and PACE data using earthaccess on a Jupyter Notebook (following instructions like those here: https://podaac.github.io/tutorials/notebooks/SearchDownload_SWOTviaCMR.html).

I'm successful with everything until I try to download data, at which point I keep getting the error "'NoneType' object has no attribute 'get': You must call earthaccess.login() before you can download data". This happens even if I use earthaccess.login(persist=True).

Any thoughts? I'd appreciate it greatly!

Filters:

NSIDC-EDL - mbeig
Posts: 22
Joined: Tue Dec 07, 2021 11:49 am America/New_York
Answers: 0

Re: "You must call earthaccess.login() before you can download data"

by NSIDC-EDL - mbeig » Mon Dec 16, 2024 6:27 pm America/New_York

Hello!
Just to double check, are you passing your Earthdata login credentials into auth=earthaccess.login() in some way? Either by setting up a .netrc file with your credentials in your home directory, setting up environment variables with your credentials, or by entering them interactively when prompted (if not using one of those previous methods)? It wasn't clear to me from your original post, and I'm not seeing those authentication instructions spelled out in the notebook that you shared. Here are some instructions: https://earthaccess.readthedocs.io/en/latest/howto/authenticate/

Let me know, if you did already use one of those methods and are still running into an issue with authentication.

Kind regards,
Mikala

ldove46
Posts: 2
Joined: Mon Dec 16, 2024 4:59 pm America/New_York
Answers: 0

Re: "You must call earthaccess.login() before you can download data"

by ldove46 » Tue Dec 17, 2024 9:05 am America/New_York

Hi Mikala,

Yes, I am entering my Earthdata login credentials into an interactive prompt. I've put this line (auth = earthaccess.login(persist=True)) right before my download call and am still getting the error I reported. I'd appreciate any other thoughts you have!

NSIDC-EDL - mbeig
Posts: 22
Joined: Tue Dec 07, 2021 11:49 am America/New_York
Answers: 0

Re: "You must call earthaccess.login() before you can download data"

by NSIDC-EDL - mbeig » Tue Dec 17, 2024 11:27 am America/New_York

Thanks for the info! Would you mind sharing your notebook/code, so that I can try to replicate the issue?

NSIDC-EDL - mbeig
Posts: 22
Joined: Tue Dec 07, 2021 11:49 am America/New_York
Answers: 0

Re: "You must call earthaccess.login() before you can download data"

by NSIDC-EDL - mbeig » Tue Dec 17, 2024 12:25 pm America/New_York

Also, are you seeing a .netrc (MacOS) or _netrc (Windows) in your home directory after you run earthaccess.login(persist=True)? And does your Earthdata Login password begin with any special characters? See this post: viewtopic.php?t=5783

Otherwise, seeing more of your code will help me be able to troubleshoot. Thanks!

I replicated the steps in the SWOT notebook you shared in your original post, and didn't run into the error you are seeing.

thomasmonahan
Posts: 1
Joined: Mon Jan 13, 2025 4:11 am America/New_York
Answers: 0

Re: "You must call earthaccess.login() before you can download data"

by thomasmonahan » Thu Jan 16, 2025 7:03 am America/New_York

I am receiving an identical error while trying to download SWOT data. I have passed my login credentials in this way: auth.login(strategy="environment", persist = True) with the username and password defined within the environment. Using this strategy several months ago gave me 0 issues when downloading SWOT data, but now no longer works. Any suggestions as to how to get around this would be much appreciated.

OB.DAAC - itcarroll
Subject Matter Expert
Subject Matter Expert
Posts: 11
Joined: Thu Nov 18, 2021 10:29 am America/New_York
Answers: 1
Been thanked: 1 time

Re: "You must call earthaccess.login() before you can download data"

by OB.DAAC - itcarroll » Thu Jan 16, 2025 12:15 pm America/New_York

thomasmonahan wrote:
> I am receiving an identical error while trying to download SWOT data. I
> have passed my login credentials in this way:
> auth.login(strategy="environment", persist = True) with the
> username and password defined within the environment. Using this strategy
> several months ago gave me 0 issues when downloading SWOT data, but now no
> longer works. Any suggestions as to how to get around this would be much
> appreciated.

The notebook referenced by OP includes the line
```
auth = earthaccess.login()
```
You can check whether login was succesfull by checking `auth.authenticated`, which should return `True`. If it's `False`, then your credentials were incorrect or not getting through. With the `persist = True` argument, you can see what credentials were used in the plain text file called ".netrc" (linux, MacOS) or "_netrc" (Windows) in your Home directory. Delete that file if they're wrong.

Note there is an existing request to have earthaccess warn you about login failures (https://github.com/nsidc/earthaccess/issues/888).

Post Reply