From 3de4096d9c3b00b477cc788d812cbdc2dbdfca12 Mon Sep 17 00:00:00 2001 From: Omar Date: Mon, 29 Nov 2021 19:30:55 +0200 Subject: [PATCH] Fix 403 auth error --- src/mapillary/models/client.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mapillary/models/client.py b/src/mapillary/models/client.py index 91cf695..3afe71e 100644 --- a/src/mapillary/models/client.py +++ b/src/mapillary/models/client.py @@ -177,7 +177,7 @@ def _initiate_request(self, url: str, method: str, params: dict = None): return res - def get(self, url: str = None, params: dict = None): + def get(self, url: str = None, params: dict = {}): """ Make GET requests to both mapillary main endpoints @@ -191,8 +191,12 @@ def get(self, url: str = None, params: dict = None): if url is None: logger.error("You need to specify an endpoint!") return - - self.session.headers.update({"Authorization": f"OAuth {self.__access_token}"}) + + # Determine Authentication method based on the requested endpoint + if "https://graph.mapillary.com" in url: + self.session.headers.update({"Authorization": f"OAuth {self.__access_token}"}) + else: + params['access_token'] = params.get('access_token', self.__access_token) return self._initiate_request(url=url, method="GET", params=params)