Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] case of automatic token refresh failure #848

Open
1 task done
itcarroll opened this issue Oct 26, 2024 · 3 comments
Open
1 task done

[BUG] case of automatic token refresh failure #848

itcarroll opened this issue Oct 26, 2024 · 3 comments

Comments

@itcarroll
Copy link
Collaborator

Is this issue already tracked somewhere, or is this a new report?

  • I've reviewed existing issues and couldn't find a duplicate for this problem.

Current Behavior

My EDL token is not getting refreshed.

import earthaccess
auth = earthaccess.login()
earthaccess.search_datasets(instrument="oci")
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
File [/srv/conda/envs/notebook/lib/python3.10/site-packages/earthaccess/search.py:86](https://oss.oel.smce.nasa.gov/srv/conda/envs/notebook/lib/python3.10/site-packages/earthaccess/search.py#line=85), in DataCollections.hits(self)
     85 try:
---> 86     response.raise_for_status()
     87 except requests.exceptions.HTTPError as ex:

File [/srv/conda/envs/notebook/lib/python3.10/site-packages/requests/models.py:1021](https://oss.oel.smce.nasa.gov/srv/conda/envs/notebook/lib/python3.10/site-packages/requests/models.py#line=1020), in Response.raise_for_status(self)
   1020 if http_error_msg:
-> 1021     raise HTTPError(http_error_msg, response=self)

HTTPError: 401 Client Error: Unauthorized for url: https://cmr.earthdata.nasa.gov/search/collections.umm_json?has_granules=true&include_granule_counts=true&instrument=oci&page_size=0

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
Cell In[1], line 3
      1 import earthaccess
      2 auth = earthaccess.login()
----> 3 earthaccess.search_datasets(instrument="oci")

File /srv/conda/envs/notebook/lib/python3.10/site-packages/earthaccess/api.py:80, in search_datasets(count, **kwargs)
     78 else:
     79     query = DataCollections().parameters(**kwargs)
---> 80 datasets_found = query.hits()
     81 logger.info(f"Datasets found: {datasets_found}")
     82 if count > 0:

File [/srv/conda/envs/notebook/lib/python3.10/site-packages/earthaccess/search.py:88](https://oss.oel.smce.nasa.gov/srv/conda/envs/notebook/lib/python3.10/site-packages/earthaccess/search.py#line=87), in DataCollections.hits(self)
     86     response.raise_for_status()
     87 except requests.exceptions.HTTPError as ex:
---> 88     raise RuntimeError(ex.response.text) from ex
     90 return int(response.headers["CMR-Hits"])

RuntimeError: {"errors":["Token [Bearer eyJXXXX_0FQ] has expired. Note the token value has been partially redacted."]}

Expected Behavior

My EDL token is expired, and I was expecting earthaccess to generate a new token for me (because #764 was purportedly fixed).

Steps To Reproduce

Wait until your EDL token expires ... then try the above.

Environment

- OS: Ubuntu 22.04.5 LTS
- Python: 3.10.14
- earthaccess installed from git commit 9784e4cee01a9d8d7514faea11cd3b80a12ae40f

Additional Context

No response

@chuckwondo
Copy link
Collaborator

This does seem strange, particularly since I believe that about a month and a half ago, I had confirmed that this automatically created a new token for me, as my EDL token had also expired at that point.

Have you created a new token yet? If not, I have something I'd like you to do to help us debug this.

@itcarroll
Copy link
Collaborator Author

Alas, I had to carry on, and created a new token. I can try what you'd like me to do on ... 12/25/2024. Or maybe someone else will experience this sooner and can try, so do tell.

@chuckwondo
Copy link
Collaborator

Alas, I had to carry on, and created a new token. I can try what you'd like me to do on ... 12/25/2024. Or maybe someone else will experience this sooner and can try, so do tell.

No worries. Mine expires on 11/11, so I'll set a reminder for myself to come back to this on 11/12, just to be sure it is expired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants