Open spatialtrail opened 3 years ago
Sorry I realise I was putting my headers in the wrong place. This almost works:
items = satsearch.Search(
url="https://services.sentinel-hub.com/api/v1/catalog",
intersects=dict(type="Point", coordinates=[-39.30, 174.05]),
collections=["sentinel-2-l2a"],
datetime='2021-01-01T00:00:00Z/2021-02-01T00:00:00Z',
limit=100
).items(headers=headers,page_limit=100)
But gives me an error:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-3-367c480f9e36> in <module>
26 # dates = f"{month_ago.strftime('%Y-%m-%d')}/{now.strftime('%Y-%m-%d')}"
27
---> 28 items = satsearch.Search(
29 url="https://services.sentinel-hub.com/api/v1/catalog",
30 intersects=dict(type="Point", coordinates=[lon, lat]),
/opt/conda/lib/python3.8/site-packages/satsearch/search.py in items(self, limit, page_limit, headers)
88 def items(self, limit=10000, page_limit=500, headers=None):
89 """ Return all of the Items and Collections for this search """
---> 90 found = self.found(headers=headers)
91 limit = self.limit or limit
92 if found > limit:
/opt/conda/lib/python3.8/site-packages/satsearch/search.py in found(self, headers)
65 found = 0
66 if 'context' in results:
---> 67 found = results['context']['matched']
68 elif 'numberMatched' in results:
69 found = results['numberMatched']
KeyError: 'matched'
https://github.com/sat-utils/sat-search/blob/master/satsearch/search.py#L67
Changing 'matched'
to 'returned'
gets me what I want though. Not sure if its because this STAC endpoint I am using is 0.9?
Hi,
I am trying to parse an oauth token to satsearch query with custom headers but am getting an error.
Following the sentinel-hub docs to get my token: https://docs.sentinel-hub.com/api/latest/api/overview/authentication/#python
Traceback:
Trying
header
instead ofheaders
I get:SatSearchError: {"code":401,"description":"You are not authorized - please provide header [Authorization: Bearer <accessToken>] with your request."}