Describe the bug
Over the last few days, authentication using the ASFSession.auth_with_creds() function does not seem to be working as it previously has been for us. i.e.
import asf_search as asf
session = asf.ASFSession()
session.auth_with_creds(earthdata_uid,earthdata_pswd) # error happens here
scene = 'S1A_IW_SLC__1SSH_20141231T080250_20141231T080317_003960_004C43_99E1'
asf_results = asf.granule_search([scene], asf.ASFSearchOptions(processingLevel='SLC'))
asf_results[0].download(path='data', session=session)
---------------------------------------------------------------------------
ASFAuthenticationError Traceback (most recent call last)
Cell In[9], [line 2](vscode-notebook-cell:?execution_count=9&line=2)
1 session = asf.ASFSession()
----> [2](vscode-notebook-cell:?execution_count=9&line=2) session.auth_with_creds(earthdata_uid,earthdata_pswd) # error happens here
4 scene = 'S1A_IW_SLC__1SSH_20141231T080250_20141231T080317_003960_004C43_99E1'
6 asf_results = asf.granule_search([scene], asf.ASFSearchOptions(processingLevel='SLC'))
File ~/mambaforge/envs/sar-pipeline/lib/python3.12/site-packages/asf_search/ASFSession.py:136, in ASFSession.auth_with_creds(self, username, password)
132 self.auth = HTTPBasicAuth(username, password)
135 # need this to set the asf-urs cookie for certain dataset downloads to work
--> [136](https://vscode-remote+ssh-002dremote-002balex-002ddev-002d3.vscode-resource.vscode-cdn.net/home/ec2-user/sar-pipeline/~/mambaforge/envs/sar-pipeline/lib/python3.12/site-packages/asf_search/ASFSession.py:136) self._legacy_creds_auth()
138 login_url = f'https://{self.edl_host}/api/users/find_or_create_token'
139 ASF_LOGGER.info(f'Attempting to get account EDL Bearer token via "{login_url}"')
File ~/mambaforge/envs/sar-pipeline/lib/python3.12/site-packages/asf_search/ASFSession.py:191, in ASFSession._legacy_creds_auth(self)
188 self.get(login_url)
190 if not self._check_auth_cookies(self.cookies.get_dict()):
--> [191](https://vscode-remote+ssh-002dremote-002balex-002ddev-002d3.vscode-resource.vscode-cdn.net/home/ec2-user/sar-pipeline/~/mambaforge/envs/sar-pipeline/lib/python3.12/site-packages/asf_search/ASFSession.py:191) raise ASFAuthenticationError('Username or password is incorrect')
193 ASF_LOGGER.info('Basic asf auth cookies set sucessfully')
195 token = self.cookies.get_dict().get('urs-access-token')
ASFAuthenticationError: Username or password is incorrect
These are valid credentials that I have tested through the ASF Vertex portal. We have also tested with other sets of credentials.
It appears a partial solution is to place the credentials in a ~/.netrc file and let the download function read them. Or similarly create a temporary file and set the NETRC envrionment variable. For example, the following scene will download correctly after creating the temp .netrc file with the same credentials that failed above:
import asf_search as asf
import tempfile
import os
with tempfile.NamedTemporaryFile("w", delete=False) as f:
f.write(
f"""machine urs.earthdata.nasa.gov
login {earthdata_uid}
password {earthdata_pswd}
"""
)
netrc_path = f.name
print(f"Temporary .netrc created at {netrc_path}")
# Set file permissions to 600 (required)
os.chmod(netrc_path, 0o600)
# tell requests/netrc-aware tools to use this file
os.environ["NETRC"] = netrc_path
scene = 'S1A_IW_SLC__1SSH_20141231T080250_20141231T080317_003960_004C43_99E1'
asf_results = asf.granule_search([scene], asf.ASFSearchOptions(processingLevel='SLC'))
asf_results[0].download(path='.')
To Reproduce
As above
Expected behavior
Authentication through the session with earthdata username and password is valid. I'm guessing it's related to this update? https://github.com/asfadmin/Discovery-asf_search/releases/tag/v10.0.5
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- asf_search==10.1.1
- OS: Amazon Linux 2023.6.20241010
- Python Version : 3.12.7
- Pip Environment :
affine @ file:///home/conda/feedstock_root/build_artifacts/affine_1733762038348/work
aioboto3 @ file:///home/conda/feedstock_root/build_artifacts/aioboto3_1742196379442/work
aiobotocore @ file:///home/conda/feedstock_root/build_artifacts/aiobotocore_1741606508148/work
aiofiles @ file:///home/conda/feedstock_root/build_artifacts/aiofiles_1733829030387/work
aiohappyeyeballs @ file:///home/conda/feedstock_root/build_artifacts/aiohappyeyeballs_1741775197943/work
aiohttp @ file:///home/conda/feedstock_root/build_artifacts/aiohttp_1759835879139/work
aioitertools @ file:///home/conda/feedstock_root/build_artifacts/aioitertools_1735329051909/work
aiosignal @ file:///home/conda/feedstock_root/build_artifacts/aiosignal_1751626463503/work
argcomplete @ file:///home/conda/feedstock_root/build_artifacts/argcomplete_1743725982721/work
argon2-cffi @ file:///home/conda/feedstock_root/build_artifacts/argon2-cffi_1749017159514/work
argon2-cffi-bindings @ file:///home/conda/feedstock_root/build_artifacts/argon2-cffi-bindings_1759486258739/work
arrow @ file:///home/conda/feedstock_root/build_artifacts/arrow_1733584251875/work
asf_search==10.1.1
attrs @ file:///home/conda/feedstock_root/build_artifacts/attrs_1759762205280/work
babel @ file:///home/conda/feedstock_root/build_artifacts/babel_1738490167835/work
backoff @ file:///home/conda/feedstock_root/build_artifacts/backoff_1733771078379/work
bcrypt @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_bcrypt_1758841782/work
boto3==1.40.48
botocore==1.40.48
branca @ file:///home/conda/feedstock_root/build_artifacts/branca_1759755605562/work
Brotli @ file:///home/conda/feedstock_root/build_artifacts/brotli-split_1756599151967/work
cached-property @ file:///home/conda/feedstock_root/build_artifacts/cached_property_1615209429212/work
cdsetool==0.2.13
certifi @ file:///home/conda/feedstock_root/build_artifacts/certifi_1759648874697/work/certifi
cffi @ file:///home/conda/feedstock_root/build_artifacts/cffi_1758716087526/work
cftime @ file:///home/conda/feedstock_root/build_artifacts/cftime_1756511800551/work
charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1754767332901/work
click @ file:///home/conda/feedstock_root/build_artifacts/click_1758270398201/work
click-plugins @ file:///home/conda/feedstock_root/build_artifacts/click-plugins_1750848229740/work
cligj @ file:///home/conda/feedstock_root/build_artifacts/cligj_1733749956636/work
colour @ file:///home/conda/feedstock_root/build_artifacts/colour_1733900183428/work
contourpy @ file:///home/conda/feedstock_root/build_artifacts/contourpy_1756544597990/work
cryptography @ file:///home/conda/feedstock_root/build_artifacts/cryptography-split_1759320353664/work
cycler @ file:///home/conda/feedstock_root/build_artifacts/cycler_1733332471406/work
dateparser==1.2.2
dem-handler @ git+https://github.com/GeoscienceAustralia/dem-handler.git@41a9331464c5e7eb52759a7ec20e961b45f88d10
dill @ file:///home/conda/feedstock_root/build_artifacts/dill_1744798524990/work
folium @ file:///home/conda/feedstock_root/build_artifacts/folium_1750113804946/work
fonttools @ file:///home/conda/feedstock_root/build_artifacts/fonttools_1759187078489/work
frozenlist @ file:///home/conda/feedstock_root/build_artifacts/frozenlist_1752167142843/work
furl @ file:///home/conda/feedstock_root/build_artifacts/furl_1741505760275/work
GDAL @ file:///home/conda/feedstock_root/build_artifacts/libgdal-core_1759340332044/work/build/swig/python
GeoAlchemy2 @ file:///home/conda/feedstock_root/build_artifacts/geoalchemy2_1684413898464/work
geopandas @ file:///home/conda/feedstock_root/build_artifacts/geopandas_1759763141056/work
greenlet @ file:///home/conda/feedstock_root/build_artifacts/greenlet_1756752082318/work
h2 @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_h2_1756364871/work
h5py==3.14.0
hpack @ file:///home/conda/feedstock_root/build_artifacts/hpack_1737618293087/work
hyperframe @ file:///home/conda/feedstock_root/build_artifacts/hyperframe_1737618333194/work
idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1733211830134/work
importlib_metadata @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_importlib-metadata_1747934053/work
importlib_resources @ file:///home/conda/feedstock_root/build_artifacts/importlib_resources_1736252299705/work
infinity @ file:///home/conda/feedstock_root/build_artifacts/infinity_1733902571227/work
intervals @ file:///home/conda/feedstock_root/build_artifacts/intervals_1733902580545/work
Jinja2 @ file:///home/conda/feedstock_root/build_artifacts/jinja2_1741263328855/work
jmespath @ file:///home/conda/feedstock_root/build_artifacts/jmespath_1733229141657/work
joblib @ file:///home/conda/feedstock_root/build_artifacts/joblib_1756321760188/work
jsonschema==4.25.1
jsonschema-specifications==2025.9.1
kiwisolver @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_kiwisolver_1756467527/work
lxml @ file:///home/conda/feedstock_root/build_artifacts/lxml_1758535129981/work
mapclassify @ file:///home/conda/feedstock_root/build_artifacts/mapclassify_1752271512095/work
markdown-it-py==4.0.0
MarkupSafe @ file:///home/conda/feedstock_root/build_artifacts/markupsafe_1759055168201/work
matplotlib==3.10.6
mdurl==0.1.2
multidict @ file:///home/conda/feedstock_root/build_artifacts/multidict_1751310558090/work
multiprocess @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_multiprocess_1756218006/work
munkres==1.1.4
netCDF4 @ file:///home/conda/feedstock_root/build_artifacts/netcdf4_1733253361203/work
networkx @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_networkx_1749078300/work
numpy @ file:///home/conda/feedstock_root/build_artifacts/numpy_1707225359967/work/dist/numpy-1.26.4-cp312-cp312-linux_x86_64.whl#sha256=031b7d6b2e5e604d9e21fc21be713ebf28ce133ec872dce6de006742d5e49bab
orderedmultidict @ file:///home/conda/feedstock_root/build_artifacts/orderedmultidict_1733900283766/work
packaging @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_packaging_1745345660/work
pandas @ file:///home/conda/feedstock_root/build_artifacts/pandas_1726878417179/work
passlib==1.7.4
pathos @ file:///home/conda/feedstock_root/build_artifacts/pathos_1744896411680/work
pendulum @ file:///home/conda/feedstock_root/build_artifacts/pendulum_1745082832615/work/rust/target/wheels/pendulum-3.1.0-cp312-cp312-linux_x86_64.whl#sha256=bed3904576c200b139038de6e5e66467c0a89da67ca28adadfb6293286ec0760
phonenumbers @ file:///home/conda/feedstock_root/build_artifacts/phonenumbers_1758881364566/work
pillow @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_pillow_1758208668/work
pox @ file:///home/conda/feedstock_root/build_artifacts/pox_1744802714626/work
ppft @ file:///home/conda/feedstock_root/build_artifacts/ppft_1744781330715/work
progressbar2 @ file:///home/conda/feedstock_root/build_artifacts/progressbar2_1734172870593/work
propcache @ file:///home/conda/feedstock_root/build_artifacts/propcache_1744524945607/work
psycopg2 @ file:///home/conda/feedstock_root/build_artifacts/psycopg2-split_1758891451670/work
pycparser @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_pycparser_1733195786/work
Pygments==2.19.2
PyJWT==2.9.0
pymap3d @ file:///home/conda/feedstock_root/build_artifacts/pymap3d_1751976266808/work
pyogrio @ file:///home/conda/feedstock_root/build_artifacts/pyogrio_1746734618835/work
pyparsing @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_pyparsing_1758436411/work
pyproj @ file:///home/conda/feedstock_root/build_artifacts/pyproj_1756536500138/work
pyroSAR @ file:///home/conda/feedstock_root/build_artifacts/pyrosar_1744210731456/work
PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1733217236728/work
pysolid @ file:///home/conda/feedstock_root/build_artifacts/pysolid_1756945314852/work
pystac==1.13.0
python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_python-dateutil_1751104122/work
python-dotenv==1.1.1
python-utils @ file:///home/conda/feedstock_root/build_artifacts/python-utils_1734115181035/work
pytz==2025.2
PyYAML @ file:///home/conda/feedstock_root/build_artifacts/pyyaml_1758891829620/work
rasterio @ file:///home/conda/feedstock_root/build_artifacts/rasterio_1758129472843/work
referencing==0.36.2
regex==2025.9.18
requests @ file:///home/conda/feedstock_root/build_artifacts/requests_1755614211359/work
rich==13.9.4
rpds-py==0.27.1
ruamel.yaml @ file:///home/conda/feedstock_root/build_artifacts/ruamel.yaml_1756838950280/work
ruamel.yaml.clib @ file:///home/conda/feedstock_root/build_artifacts/ruamel.yaml.clib_1756828682847/work
s1_orbits==0.2.0
s1etad @ file:///home/conda/feedstock_root/build_artifacts/s1etad_1751707312604/work
s1etad-tools @ file:///home/antonio/anaconda3/conda-bld/s1etad_tools_1648047441355/work
s1reader @ file:///home/conda/feedstock_root/build_artifacts/s1reader_1746193778159/work
s3transfer==0.14.0
-e git+https://github.com/GeoscienceAustralia/sar-pipeline.git@a1074ad24ad2b15bb5d6b21d896b6fec0dbbf3f4#egg=sar_pipeline
scikit-learn @ file:///home/conda/feedstock_root/build_artifacts/scikit-learn_1757406006820/work/dist/scikit_learn-1.7.2-cp312-cp312-linux_x86_64.whl#sha256=129fb53912f867c66de404c45e47a17c8d2466e12961a80dadee213c841e7450
scipy @ file:///home/conda/feedstock_root/build_artifacts/scipy-split_1757681062691/work/dist/scipy-1.16.2-cp312-cp312-linux_x86_64.whl#sha256=e57867dfada19f0ed109f6f12e596070dc20edae378c1997972421594e5d505b
sentineleof @ file:///home/conda/feedstock_root/build_artifacts/sentineleof_1753437450366/work
setuptools==80.9.0
setuptools-scm @ file:///home/conda/feedstock_root/build_artifacts/setuptools_scm_1755378629324/work
shapely @ file:///home/conda/feedstock_root/build_artifacts/shapely_1758735219922/work
shellingham==1.5.4
simplekml @ file:///home/conda/feedstock_root/build_artifacts/simplekml_1734959908868/work
six @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_six_1753199211/work
snuggs @ file:///home/conda/feedstock_root/build_artifacts/snuggs_1733818638588/work
spatialist @ file:///home/conda/feedstock_root/build_artifacts/spatialist_1759906451747/work
SQLAlchemy @ file:///home/conda/feedstock_root/build_artifacts/sqlalchemy_1731848259964/work
SQLAlchemy-Utils @ file:///home/conda/feedstock_root/build_artifacts/sqlalchemy-utils-split_1756597255185/work
tblib @ file:///home/conda/feedstock_root/build_artifacts/tblib_1743515515538/work
tenacity==9.1.2
threadpoolctl @ file:///home/conda/feedstock_root/build_artifacts/threadpoolctl_1741878222898/work
time-machine @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_time-machine_1756482573/work/dist
tomli @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_tomli_1753796677/work
typer==0.19.2
types-python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/types-python-dateutil_1759899809376/work
typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_typing_extensions_1756220668/work
tzdata @ file:///home/conda/feedstock_root/build_artifacts/python-tzdata_1742745135198/work
tzlocal==5.3.1
unicodedata2 @ file:///home/conda/feedstock_root/build_artifacts/unicodedata2_1756494453070/work
urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1750271362675/work
wheel==0.45.1
wrapt @ file:///home/conda/feedstock_root/build_artifacts/wrapt_1756851611084/work
xyzservices @ file:///home/conda/feedstock_root/build_artifacts/xyzservices_1745598038694/work
yamale @ file:///home/conda/feedstock_root/build_artifacts/yamale_1735891169111/work
yarl @ file:///home/conda/feedstock_root/build_artifacts/yarl_1749554822108/work
zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1749421620841/work
zstandard==0.25.0
Additional context
Add any other context about the problem here.
Describe the bug
Over the last few days, authentication using the ASFSession.auth_with_creds() function does not seem to be working as it previously has been for us. i.e.
These are valid credentials that I have tested through the ASF Vertex portal. We have also tested with other sets of credentials.
It appears a partial solution is to place the credentials in a
~/.netrcfile and let the download function read them. Or similarly create a temporary file and set the NETRC envrionment variable. For example, the following scene will download correctly after creating the temp.netrcfile with the same credentials that failed above:To Reproduce
As above
Expected behavior
Authentication through the session with earthdata username and password is valid. I'm guessing it's related to this update? https://github.com/asfadmin/Discovery-asf_search/releases/tag/v10.0.5
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.