From the PO.DAAC Cookbook, to access the GitHub version of the notebook, follow this link.

How to Authenticate for NASA Earthdata Programmatically

Earthdata Login

An Earthdata Login account is required to access data, as well as discover restricted data, from the NASA Earthdata system. Thus, to access NASA data, you need Earthdata Login. Please visit https://urs.earthdata.nasa.gov to register and manage your Earthdata Login account. This account is free to create and only takes a moment to set up.

We recommend programmatic authentication with a few lines of code using the earthaccess python package.

import earthaccess

auth = earthaccess.login(strategy="interactive", persist=True)

The line above has you login to Earthdata and persists the credentials in a netrc file in your home directory behind the scenes. If you know you already have a netrc file, you can also authenticate with the following, without typing in your login credentials each time:

auth = earthaccess.login(strategy="netrc")

Authentication is also possible without the earthaccess package; please review this 2021 Cloud Hackathon Authentication tutorial for more details.