URS not working for NSIDC OPeNDAP
See original GitHub issueI am attempting to access a granule in the NSIDC ECS OPeNDAP instance using pydap, but unable to successfully authenticate with URS. Looking at PR #57, I would expect this to work when using pydap v3.2.2:
from pydap.client import open_url
from pydap.cas.urs import setup_session
url = 'https://n5eil02u.ecs.nsidc.org/opendap/OTHR/NISE.004/2012.10.02/NISE_SSMISF17_20121002.HDFEOS'
session = setup_session(os.environ['EARTHDATA_USER'], os.environ['EARTHDATA_PASS'], check_url=url)
open_url(url, session=session)
Returns an HTTPError that looks like a redirect is not being followed.
HTTPError Traceback (most recent call last)
<ipython-input-7-4a425d17a509> in <module>
----> 1 open_url('https://n5eil02u.ecs.nsidc.org/opendap/OTHR/NISE.004/2012.10.02/NISE_SSMISF17_20121002.HDFEOS.html')
~/.pyenv/versions/miniconda3-latest/envs/test/lib/python3.7/site-packages/pydap/client.py in open_url(url, application, session, output_grid, timeout)
65 """
66 dataset = DAPHandler(url, application, session, output_grid,
---> 67 timeout).dataset
68
69 # attach server-side functions
~/.pyenv/versions/miniconda3-latest/envs/test/lib/python3.7/site-packages/pydap/handlers/dap.py in __init__(self, url, application, session, output_grid, timeout)
52 ddsurl = urlunsplit((scheme, netloc, path + '.dds', query, fragment))
53 r = GET(ddsurl, application, session, timeout=timeout)
---> 54 raise_for_status(r)
55 if not r.charset:
56 r.charset = 'ascii'
~/.pyenv/versions/miniconda3-latest/envs/test/lib/python3.7/site-packages/pydap/net.py in raise_for_status(response)
37 detail=response.status+'\n'+response.text,
38 headers=response.headers,
---> 39 comment=response.body
40 )
41
HTTPError: 302 Found
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://urs.earthdata.nasa.gov/oauth/authorize?client_id=PGVMJ5nUzSnQkI5o23gMxA&response_type=code&redirect_uri=https%3A%2F%2Fn5eil02u.ecs.nsidc.org%2FOPS%2Fredirect&state=aHR0cHM6Ly9uNWVpbDAydS5lY3MubnNpZGMub3JnL29wZW5kYXAvT1RIUi9OSVNFLjAwNC8yMDEyLjEwLjAyL05JU0VfU1NNSVNGMTdfMjAxMjEwMDIuSERGRU9TLmh0bWwuZGRz">here</a>.</p>
</body></html>
I tried tracing the execution down to the webob.Request
but I am not sure at that point what I should be seeing for this to work. Any help much appreciated!
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
How do I access data using OPeNDAP?
With a URL to an OPeNDAP server, users can browse data, perform subset operations, and open data directly in NetCDF-compliant software and tools ......
Read more >Use cases for swath and time series aggregation
Use cases for satellite Swath and Time Series aggregation. Our general approach is to use the Sequence data type to aggregate granules from ......
Read more >Access NSIDC AMSR HDF-EOS5 via OPeNDAP - Earthdata
This API allows access to visualize AMSR HDF-EOS5 from NSIDC DAAC ... For large subset of data, this code will not work for...
Read more >EarthData Cloud Cookbook - PO DAAC Authentication Example
machine urs.earthdata.nasa.gov login jmcnelis password machine opendap.earthdata.nasa.gov ... Dump the netrc again sans passwords to confirm that it worked:.
Read more >access to MERRA-2 using opendap - Google Groups
http://legras:<my_passwd>@goldsmr5.sci.gsfc.nasa.gov/opendap/hyrax/MERRA2/M2T3NVRAD. ... It was working perfectly one year ago and does not work anymore.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks to Peter L. Smith at Raytheon for this workaround and the following explanation:
Likewise, the issue persists.
I think that the fix described by @wallinb works, but it also seems to download the entire file:
session = get_session(url)
gives this debug message:2020-09-28 13:57:22,176 - urllib3.connectionpool - DEBUG - https://ladsweb.modaps.eosdis.nasa.gov:443 "GET /archive/allData/5200/VJ102IMG/2020/225/VJ102IMG.A2020225.0418.002.2020225101640.nc HTTP/1.1" 200 268321100
And there’s a long pause before python becomes active again, which makes me think it’s downloading the file.