What is the way to pass Earthdata login credentials to directly download a granule file using Java?
- User Services
- Posts: 247
- Joined: Mon Sep 30, 2019 12:39 pm America/New_York
- Has thanked: 8 times
I have forwarded your inquiry to our Subject Matter Expert for some guidance.
Data Prep Scripts can be found here: https://lpdaac.usgs.gov/tools/data-prep-scripts/
This collection of R and Python scripts can be used to download data and perform basic data processing functions such as georeferencing, reprojecting, converting, and reformatting data. Scripts are available in Python and/or R and each have a README that provides additional information. All scripts are available for download from the LP DAAC User Resources BitBucket Code Repository (https://git.earthdata.nasa.gov/projects/LPDUR).
I have tried the Java example here: https://wiki.earthdata.nasa.gov/display/EL/How+To+Access+Data+With+Java. I supply my Earthdata credentials as described in the sample code along with the granule URL in my previous post. The response back goes through 3 redirects (HTTP 302) to OAuth and then finally to a HTTP 403 login error. So what am I doing wrong?
A working example performing a download of one file would be great to see. Don't just click on a link once you are on a website with a previous authentication... I can do that also to get the download... but I would like to run a Java program outside of a browser to perform the download.
We've taken a look at the Java code you linked to on the Earthdata Login wiki page (https://wiki.earthdata.nasa.gov/display/EL/How+To+Access+Data+With+Java). We were not able to replicate your error message. In fact, we were not able to download a valid .zip file using the Java code provided. The Java code was not developed nor is it maintained by the LP DAAC. We have passed on the issue on to the team responsible for that code, however, I do not have a time frame for its work. In the meantime I would recommend the resources we maintain in our BitBucket Code Repository (https://git.earthdata.nasa.gov/projects/LPDUR), which is primarily Python resources. Additionally, if you're looking for just downloads, we have resource for downloading using wget or cURL.