Non-interactive downlaods through Earthdata login
Posted: Wed Nov 20, 2019 4:36 pm America/New_York
With regards to the recently announced move the requiring EarthData login for data downloads, we have been unable to make non-interactive downloads work using the guidance at https://oceancolor.gsfc.nasa.gov/data/download_methods/. Using a HICO file as a test, as it is already requires EarthData login, attempting to download the file results in the source code for the login page being retrieved instead:
Attempting to store my credentials via the ~/.netrc file and calling wget with a cookie fares no better:
Using curl yields similar results. I am able to successfully download HICO files using the web browser. Any ideas why I am unable to successfully download a file with Earthdata login non-interactively?
Thanks,
Benjamin McCabe/Computer Scientist, Direct Readout Laboratory
NASA/Goddard Space Flight Center
http://directreadout.sci.gsfc.nasa.gov/
https://www.facebook.com/directreadout/
https://twitter.com/NASA_DRL
[bmccabe1@sora ~]$ wget --user=b.mccabe --password='mypassword' https://oceandata.sci.gsfc.nasa.gov/hico/getfile/H2014255140230.L2_ISS_OC.nc
--2019-11-20 21:17:41-- https://oceandata.sci.gsfc.nasa.gov/hico/getfile/H2014255140230.L2_ISS_OC.nc
Resolving oceandata.sci.gsfc.nasa.gov (oceandata.sci.gsfc.nasa.gov)... xx.xxx.xx.xx, 2001:4d0:2418:128::84
Connecting to oceandata.sci.gsfc.nasa.gov (oceandata.sci.gsfc.nasa.gov)|xx.xxx.xx.xx|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://urs.earthdata.nasa.gov/oauth/authorize?client_id=Nwx7SywSELFPjkOk6Ifsjw&response_type=code&redirect_uri=https%3A%2F%2Foceandata.sci.gsfc.nasa.gov%2Fhico%2Fgetfile%2Frestrict [following]
--2019-11-20 21:17:42-- https://urs.earthdata.nasa.gov/oauth/authorize?client_id=Nwx7SywSELFPjkOk6Ifsjw&response_type=code&redirect_uri=https%3A%2F%2Foceandata.sci.gsfc.nasa.gov%2Fhico%2Fgetfile%2Frestrict
Resolving urs.earthdata.nasa.gov (urs.earthdata.nasa.gov)... xx.xxx.xx.xx, 2001:4d0:241a:4081::89
Connecting to urs.earthdata.nasa.gov (urs.earthdata.nasa.gov)|xx.xxx.xx.xx|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘H2014255140230.L2_ISS_OC.nc’
[ <=> ] 12,663 --.-K/s in 0.001s
2019-11-20 21:17:42 (14.9 MB/s) - ‘H2014255140230.L2_ISS_OC.nc’ saved [12663]
[bmccabe1@sora ~]$ head -n 10 H2014255140230.L2_ISS_OC.nc
<!DOCTYPE html>
<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]><html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--><html lang="en" class="no-js"><!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Earthdata Login</title>
<meta name="description" content="Earthdata Login">
Attempting to store my credentials via the ~/.netrc file and calling wget with a cookie fares no better:
[bmccabe1@sora ~]$ rm H2014255140230.L2_ISS_OC.nc
[bmccabe1@sora ~]$ echo 'machine urs.earthdata.nasa.gov login b.mccabe password mypassword' > ~/.netrc
[bmccabe1@sora ~]$ chmod 0600 ~/.netrc
[bmccabe1@sora ~]$ touch ~/.urs_cookies
[bmccabe1@sora ~]$ wget --load-cookies ~/.urs_cookies --save-cookies ~/.urs_cookies --keep-session-cookies https://oceandata.sci.gsfc.nasa.gov/hico/getfile/H2014255140230.L2_ISS_OC.nc
--2019-11-20 21:23:32-- https://oceandata.sci.gsfc.nasa.gov/hico/getfile/H2014255140230.L2_ISS_OC.nc
Resolving oceandata.sci.gsfc.nasa.gov (oceandata.sci.gsfc.nasa.gov)... xx.xxx.xx.xx, 2001:4d0:2418:128::84
Connecting to oceandata.sci.gsfc.nasa.gov (oceandata.sci.gsfc.nasa.gov)|xx.xxx.xx.xx|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://urs.earthdata.nasa.gov/oauth/authorize?redirect_uri=https%3A%2F%2Foceandata.sci.gsfc.nasa.gov%2Fhico%2Fgetfile%2Frestrict&response_type=code&client_id=Nwx7SywSELFPjkOk6Ifsjw [following]
--2019-11-20 21:23:32-- https://urs.earthdata.nasa.gov/oauth/authorize?redirect_uri=https%3A%2F%2Foceandata.sci.gsfc.nasa.gov%2Fhico%2Fgetfile%2Frestrict&response_type=code&client_id=Nwx7SywSELFPjkOk6Ifsjw
Resolving urs.earthdata.nasa.gov (urs.earthdata.nasa.gov)... xx.xxx.xx.xx, 2001:4d0:241a:4081::89
Connecting to urs.earthdata.nasa.gov (urs.earthdata.nasa.gov)|xx.xxx.xx.xx|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘H2014255140230.L2_ISS_OC.nc’
[ <=> ] 12,663 --.-K/s in 0.001s
2019-11-20 21:23:32 (14.6 MB/s) - ‘H2014255140230.L2_ISS_OC.nc’ saved [12663]
[bmccabe1@sora ~]$ head -n 10 H2014255140230.L2_ISS_OC.nc
<!DOCTYPE html>
<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]><html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--><html lang="en" class="no-js"><!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Earthdata Login</title>
<meta name="description" content="Earthdata Login">
Using curl yields similar results. I am able to successfully download HICO files using the web browser. Any ideas why I am unable to successfully download a file with Earthdata login non-interactively?
Thanks,
Benjamin McCabe/Computer Scientist, Direct Readout Laboratory
NASA/Goddard Space Flight Center
http://directreadout.sci.gsfc.nasa.gov/
https://www.facebook.com/directreadout/
https://twitter.com/NASA_DRL