landstac.auth¶
ERS authentication and session helpers.
Functions: - make_session: create a requests.Session with retries and headers - ers_login: log in to ERS (USGS) and return an authenticated session - ers_login_from_file: read credentials.json and log in - save_cookies_for_gdal: export session cookies to a Mozilla cookie file so
GDAL/rasterio can stream protected assets without downloading
Functions
|
Log in to ERS and return an authenticated session. |
|
Read credentials.json and perform ERS login. |
|
Save current session cookies into a Mozilla cookie file. |
- landstac.auth.ers_login(username, password, token=None)[source]¶
Log in to ERS and return an authenticated session.
- Parameters:
- Returns:
Authenticated session with ERS cookies.
- Return type:
requests.Session
Note
If token is provided and accepted by the host, it is attached as Authorization header.
- landstac.auth.ers_login_from_file(credentials_path='credentials.json')[source]¶
Read credentials.json and perform ERS login.
- Parameters:
credentials_path (str) – Path to credentials JSON file.
- Returns:
Authenticated session.
- Return type:
requests.Session
Note
credentials.json schema:
{ "username": "...", "password": "...", "token": null }
- landstac.auth.save_cookies_for_gdal(session, cookiefile='usgs_cookies.txt')[source]¶
Save current session cookies into a Mozilla cookie file.
- Parameters:
session (requests.Session) – Authenticated session.
cookiefile (str) – Path to save cookie file.
- Returns:
Absolute path to saved cookie file.
- Return type:
Note
Use with GDAL via environment variables:
CPL_CURL_COOKIEFILE=cookiefile CPL_CURL_COOKIEJAR=cookiefile