Replies: 2 comments 5 replies
|
The Here is the list functions being called when using custom STAC catalogs. Line 5175 in cd24114 Line 1316 in cd24114 Line 1229 in cd24114 Line 1286 in cd24114 https://pystac-client.readthedocs.io/en/stable/api.html#pystac_client.Client.open open(url, headers=None, parameters=None, ignore_conformance=None, modifier=None, request_modifier=None, stac_io=None, timeout=None) |
|
The custom STAC GUI can authenticate, but credentials should not be embedded in the URL. The current For HTTP Basic authentication: import base64
import getpass
import leafmap
from leafmap.toolbar import stac_custom_gui
username = input("STAC username: ")
password = getpass.getpass("STAC password: ")
credentials = base64.b64encode(
f"{username}:{password}".encode("utf-8")
).decode("ascii")
headers = {
"Authorization": f"Basic {credentials}",
}
catalogs = {
"Private STAC": "https://stac-api.example.com",
}
m = leafmap.Map(center=[40, -100], zoom=4)
m.set_catalog_source(catalogs)
stac_custom_gui(m, headers=headers)
mFor a bearer/API token, only the header changes: import getpass
token = getpass.getpass("STAC token: ")
headers = {"Authorization": f"Bearer {token}"}
stac_custom_gui(m, headers=headers)This works because the same
A useful non-GUI check is: from leafmap.stac import stac_client
client, catalog_id = stac_client(
"https://stac-api.example.com",
headers=headers,
get_root=False,
)
print(catalog_id)
print([collection.id for collection in client.get_collections()])Security notes:
The public |

Uh oh!
There was an error while loading. Please reload this page.
Is there a way to include authentication (e.g., Basic Auth) when accessing a STAC catalog in Leafmap?
I'm currently using the following code in a Jupyter Notebook to load STAC catalogs:
Some STAC catalogs require authentication (e.g., API keys, Basic Auth). I tried modifying the URL to include credentials, like this:
However, this results in the following error:
Is there a proper way to pass authentication credentials when loading a STAC catalog in Leafmap? Any guidance would be appreciated.
Thanks!
All reactions