icepyx icon indicating copy to clipboard operation
icepyx copied to clipboard

switch Earthdata login token from Echo to Bearer

Open JessicaS11 opened this issue 2 years ago • 3 comments

NASA supports 2 token types:

  • Echo-tokens: These are being deprecated, you can pass them as a simple parameter in your query to CMR, they are valid for 3 months after being issued.
  • Bearer tokens: They are passed in the authorization header and are technically valid for 3 months but there is a bug now on CMR that makes them valid for one week only. That's going to be fixed soon.

This curl command should give you 2 ATL03 collections (v3 and v4), both hosted at NSIDC:

curl https://cmr.earthdata.nasa.gov/search/collections.json?short_name=ATL03

If you have an Echo token you'll get 3 results, the 3rd is the cloud collection:

curl https://cmr.earthdata.nasa.gov/search/collections.json?short_name=ATL03&token=TOKEN

Now with a bearer token

curl -H "Authorization: Bearer EDL-XXX" https://cmr.earthdata.nasa.gov/search/collections.json?short_name=ATL03

I'm working on a project to facilitate all this and I hope I can release it soon (next week) maybe it will be of use for Icepyx

Originally posted by @betolink in https://github.com/icesat2py/icepyx/pull/213#discussion_r728220421

We need to update icepyx to use the newer token type. This will also involve updating the requests with the updated authentication syntax:

The requests syntax would be:

requests.get(cmr_collections_url, headers={"Authorization": f"Bearer {sessionToken}"}, params={"short_name": "ATL03"})

sessionToken start with EDL- (echo tokens look like UUIDs) the same applies to cmr_granules_url. I need to take a look at the granule search code and see if this library can be of use here, I hope so!

JessicaS11 avatar Oct 15 '21 15:10 JessicaS11

We (NSIDC) were recently informed that echo tokens will no longer be supported 'soon'. I'm not sure what the exact timeframe is, but we've been advised to eliminate our use of echo tokens ASAP.

As I was searching our code for instances of the echo token endpoint, I noticed it's use in icepyx.core.Earthdata and came here to open an issue, but found this existing one!

This page has some additional information that might be useful for completing this task: https://wiki.earthdata.nasa.gov/display/CMR/ECHO+Token+Retirement+Migration+Plan

trey-stafford avatar Jul 19 '22 22:07 trey-stafford

I received an update this morning: echo tokens will be phased out in January 2023.

trey-stafford avatar Jul 20 '22 16:07 trey-stafford

Thanks for letting us know, @trey-stafford, and for sharing some resources!

JessicaS11 avatar Jul 22 '22 20:07 JessicaS11

Hi @JessicaS11, echo tokens are not deprecated just yet but they will be soon. I wonder if I can help with the transition, either natively in icepyx or using earthaccess.

betolink avatar Feb 23 '23 21:02 betolink

Hey @betolink. Thanks! I was waiting for v0.5.0 of earthaccess so I could transition icepyx to using that for authentication. Can I ping you to review the PR once it's ready?

JessicaS11 avatar Feb 28 '23 20:02 JessicaS11

@betolink Could you also let me now if I should try to port any of our previous Earthdata module tests over to earthaccess? I'm still getting the hang of anything beyond basic tests, so I'm having trouble quickly discerning if any of the "try these auth options sequentially" testing would be useful there or is already covered.

JessicaS11 avatar Feb 28 '23 21:02 JessicaS11

Hi @JessicaS11 sure! earthaccess has only one test for the interactive login, I think we should add yours for the netrc file. I can start prototyping something for Icepyx tomorrow, we might want to add the email handling to earthaccess while we are at it.

betolink avatar Mar 02 '23 15:03 betolink

ah before I forget, echo tokens will be down next Thursday morning, (March 9th) for a test, I think between 9 and noon ET.

betolink avatar Mar 02 '23 15:03 betolink