Skip to content

satsearch.Search error with headers #119

@spatialtrail

Description

@spatialtrail

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

headers = {"Authorization": f"Bearer {token['access_token']}"}
items = satsearch.Search(
    url="https://services.sentinel-hub.com/api/v1/catalog",
    headers=headers,
    intersects=dict(type="Point", coordinates=[-39.30, 174.05]),
    collections=["sentinel-2-l2a"],
    datetime="2021-01-01/2021-02-01"
).items()

Traceback:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<timed exec> in <module>

/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)
     60         url = urljoin(self.url, 'search')
     61 
---> 62         results = self.query(url=url, headers=headers, **kwargs)
     63         # TODO - check for status_code
     64         logger.debug(f"Found: {json.dumps(results)}")

TypeError: query() got multiple values for keyword argument 'headers'

Trying header instead of headers I get:
SatSearchError: {"code":401,"description":"You are not authorized - please provide header [Authorization: Bearer <accessToken>] with your request."}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions