Skip to content

Commit

Permalink
Update Generate Earthdata Login Token (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
g4brielvs committed Jun 26, 2024
1 parent 4de8da2 commit a857074
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 25 deletions.
Binary file added docs/images/nasa_earthdata_generate_token.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/nasa_earthdata_profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/images/nasa_laads_login.png
Binary file not shown.
61 changes: 36 additions & 25 deletions notebooks/blackmarblepy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -81,47 +81,58 @@
"id": "a79340b3-c016-481e-bdb0-aa1c615c71c3",
"metadata": {},
"source": [
"### Create NASA Earthdata Bearer Token\n",
"### Generate NASA Earthdata Token\n",
"\n",
"**BlackMarblePy** requires using [NASA Earthdata](**BlackMarblePy**) **bearer token**. To obtain a token, please follow the steps below:\n",
"**BlackMarblePy** requires a [NASA Earthdata](https://urs.earthdata.nasa.gov) **bearer token**. To generate a token, you may use [Earthdata Login](https://urs.earthdata.nasa.gov/documentation)\n",
"\n",
"1. Go to the [NASA LAADS Archive](https://ladsweb.modaps.eosdis.nasa.gov/archive/allData/5000/VNP46A3/)\n",
"2. Click \"Login\" (bottom on top right); create an account if needed.\n",
"3. Click \"See wget Download Command\" (bottom near top, in the middle)\n",
"4. After clicking, you will see text that can be used to download data. The \"Bearer\" token will be a long string in red.\n",
"1. Access [Earthdata Login](https://urs.earthdata.nasa.gov/profile). In case you haven't already, you must [register](https://urs.earthdata.nasa.gov/users/new).\n",
" ```{figure} ../images/nasa_earthdata_profile.png\n",
" ---\n",
" height: 150px\n",
" ---\n",
"2. Select **Generate Token**. If the token is expired or you are in need of one, click the **Generate Token** button. \n",
" ```{figure} ../images/nasa_earthdata_generate_token.png\n",
" ---\n",
" height: 400px\n",
" ---\n",
"3. Copy and use the token securely with [BlackMarblePy](https://worldbank.github.io/blackmarblepy/api/blackmarble.html)\n",
" ```python\n",
" import os\n",
"\n",
"````{tip}\n",
"__After logging in, the below will show the bearer token in red instead of `INSERT_DOWNLOAD_TOKEN_HERE`.__ Sometimes, after logging in, the NASA website will redirect to another part of the website. To obtain the bearer token, just navigate to the [NASA LAADS Archive](https://ladsweb.modaps.eosdis.nasa.gov/archive/allData/5000/VNP46A3/) after logging in.\n",
"\n",
"```{figure} ../images/nasa_laads_login.png\n",
"---\n",
"height: 200px\n",
"---\n",
"````"
]
},
{
"cell_type": "markdown",
"id": "cc878977-7626-4f07-b2a7-d8d727e05134",
"metadata": {},
"source": [
"### Define NASA bearer token \n",
"\n",
"For instructions on obtaining a NASA bearer token, please see above."
" bearer = os.getenv(\"BLACKMARBLE_TOKEN\")\n",
" ```"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "fea5c8fa-199c-4f8d-aea1-7a725e9381c7",
"metadata": {
"tags": []
"tags": [
"remove-cell"
]
},
"outputs": [],
"source": [
"bearer = os.getenv(\"BLACKMARBLE_TOKEN\")"
]
},
{
"cell_type": "markdown",
"id": "6eaaeb6e",
"metadata": {},
"source": [
"\n",
"```{important}\n",
"Using a secret token securely in Python code involves several practices to ensure the token is not exposed unintentionally. For instance, storing the secret token in an environment variable, in configuration files or using secret management services. In this example, we set up an environment variable.\n",
"```\n",
"\n",
"```{seealso}\n",
"- [Using Secrets Securely](https://worldbank.github.io/template/notebooks/nasa-apod.html)\n",
"- [Best Practices for Securing API Keys](https://rapidapi.com/guides/practices-api-keys)\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "f1cce32c-f001-4324-9aeb-1246a3044457",
Expand Down

0 comments on commit a857074

Please sign in to comment.