#!/usr/bin/env python # coding: utf-8 # # Struggling with ABFS credentials # In[1]: import pystac_client import xarray as xr # In[2]: from pystac_client.stac_api_io import StacApiIO from pystac_client.client import Client stac_api_io = StacApiIO() catalog = Client.open("https://planetarycomputer.microsoft.com/api/stac/v1", stac_io=stac_api_io) # In[3]: sas_token = stac_api_io.session.get("https://planetarycomputer.microsoft.com/api/sas/v1/token/cil-gdpcir-cc0").json()["token"] # In[4]: catalog = catalog.get_collection("cil-gdpcir-cc0") # In[5]: item = next(catalog.get_all_items()) # In[6]: asset = item.assets["pr"] asset.href # ## Storage options work here for xarray: # In[7]: storage_options = {"account_name": "rhgeuwest", "sas_token": sas_token} # In[8]: ds = xr.open_dataset(asset.href, engine="zarr", consolidated=True, chunks={}, storage_options=storage_options) # In[9]: ds # ## Storage options don't work here for fsspec: # In[10]: import fsspec # In[11]: fs = fsspec.filesystem('abfs', storage_options=storage_options) # In[ ]: