Skip to content

Ignore EARTHDATA_USERNAME/PASSWORD when EARTHDATA_TOKEN is set - #1122

Merged
betolink merged 6 commits into
mainfrom
skip-basicauth-if-token
Nov 5, 2025
Merged

Ignore EARTHDATA_USERNAME/PASSWORD when EARTHDATA_TOKEN is set#1122
betolink merged 6 commits into
mainfrom
skip-basicauth-if-token

Conversation

@chuckwondo

@chuckwondo chuckwondo commented Oct 31, 2025

Copy link
Copy Markdown
Contributor
Pull Request (PR) draft checklist - click to expand
  • Please review our
    contributing documentation
    before getting started.
  • Populate a descriptive title. For example, instead of "Updated README.md", use a
    title such as "Add testing details to the contributor section of the README".
    Example PRs: #763
  • Populate the body of the pull request with:
  • Update CHANGELOG.md with details about your change in a section titled
    ## Unreleased. If such a section does not exist, please create one. Follow
    Common Changelog for your additions.
    Example PRs: #763
  • Update the documentation and/or the README.md with details of changes to the
    earthaccess interface, if any. Consider new environment variables, function names,
    decorators, etc.

Click the "Ready for review" button at the bottom of the "Conversation" tab in GitHub
once these requirements are fulfilled. Don't worry if you see any test failures in
GitHub at this point!

Pull Request (PR) merge checklist - click to expand

Please do your best to complete these requirements! If you need help with any of these
requirements, you can ping the @nsidc/earthaccess-support team in a comment and we
will help you out!

  • Add unit tests for any new features.
  • Apply formatting and linting autofixes. You can add a GitHub comment in this Pull
    Request containing "pre-commit.ci autofix" to automate this.
  • Ensure all automated PR checks (seen at the bottom of the "conversation" tab) pass.
  • Get at least one approving review.

Fixes #1121


📚 Documentation preview 📚: https://earthaccess--1122.org.readthedocs.build/en/1122/

@chuckwondo
chuckwondo requested a review from mfisher87 October 31, 2025 22:51
@github-actions

github-actions Bot commented Oct 31, 2025

Copy link
Copy Markdown

Binder 👈 Launch a binder notebook on this branch for commit 50e149d

I will automatically update this comment whenever this PR is modified

Binder 👈 Launch a binder notebook on this branch for commit 5cff7ed

Binder 👈 Launch a binder notebook on this branch for commit 5d1dc67

Binder 👈 Launch a binder notebook on this branch for commit 95d9f3b

Binder 👈 Launch a binder notebook on this branch for commit 0ebeb70

Binder 👈 Launch a binder notebook on this branch for commit 3af74a8

Binder 👈 Launch a binder notebook on this branch for commit d2af3ed

@chuckwondo
chuckwondo requested a review from betolink October 31, 2025 22:52
@chuckwondo

Copy link
Copy Markdown
Contributor Author

pre-commit.ci autofix

@chuckwondo
chuckwondo force-pushed the skip-basicauth-if-token branch from 0ebeb70 to 3af74a8 Compare November 4, 2025 19:24
@chuckwondo

Copy link
Copy Markdown
Contributor Author

@betolink, @mfisher87, @jhkennedy, the integration tests seem to be regularly failing with the following, but re-running them clears things up. It seems odd that we get JSONDecodeErrors that go away on re-runs:

_____________ test_get_s3_filesystem_lowercase_location[location0] _____________
Traceback (most recent call last):
  File "/home/runner/work/***/***/.venv/lib/python3.13/site-packages/requests/models.py", line 976, in json
    return complexjson.loads(self.text, **kwargs)
           ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.13.9/x64/lib/python3.13/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^
  File "/opt/hostedtoolcache/Python/3.13.9/x64/lib/python3.13/json/decoder.py", line 345, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.13.9/x64/lib/python3.13/json/decoder.py", line 363, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

@betolink betolink left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready to merge just noting that we may need to improve out auth unit test in the future,

Comment thread earthaccess/auth.py
self.token = {"access_token": user_token}
self.authenticated = True
if username is not None and password is not None:
elif username is not None and password is not None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great catch, I don't like these if but we have n different ways of signing in.

Comment thread tests/unit/test_store.py
@@ -17,9 +17,15 @@

class TestStoreSessions(unittest.TestCase):
@responses.activate

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a test that test both token and EDL credentials are present? other than that I think the code change in auth addresses the core issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review @betolink. Yes, we'll probably want to add more tests to test various combinations of existing/non-existing env vars to cover the various cases to test for interference/precedence. I suspect that this can be covered in the context of work on the other auth issues in the backlog.

@betolink
betolink merged commit fb8a754 into main Nov 5, 2025
15 of 17 checks passed
@betolink
betolink deleted the skip-basicauth-if-token branch November 5, 2025 15:55
@github-project-automation github-project-automation Bot moved this to ✅ Done in earthaccess Mar 3, 2026
@mfisher87 mfisher87 removed this from earthaccess Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] When EARTHDATA_TOKEN is set, and EARTHDATA_USERNAME and EARTHDATA_PASSWORD are also set, the latter should be ignored, but are not

3 participants