From ab353b7052d41b0615a49ade2238b4c5984f9b35 Mon Sep 17 00:00:00 2001 From: Andreas Predikaka Date: Mon, 5 Feb 2024 12:00:05 +0100 Subject: [PATCH] Replace all HTTP 403 codes with 401 codes for more appropriate authorization handling --- webarchiv.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webarchiv.py b/webarchiv.py index 3076c64..384e139 100644 --- a/webarchiv.py +++ b/webarchiv.py @@ -111,7 +111,7 @@ class WebarchivSession: @staticmethod def _handle_response_errors(r): - if r.status_code == 403: + if r.status_code == 401: print('Forbidden. Invalid Token or ApiKey transmitted', file=sys.stderr) return r elif r.status_code == 400: @@ -125,7 +125,7 @@ class WebarchivSession: r = requests.get(self.base_url.format(op), **kwargs) if r.ok: return r - elif r.status_code == 403 and auto_connect: + elif r.status_code == 401 and auto_connect: self.connect() kwargs['headers'] = { 'Authorization': 'Bearer ' + self.token @@ -155,7 +155,7 @@ class WebarchivSession: r = requests.post(self.base_url.format(op), json=json, **kwargs) if r.status_code == 201: return r - elif r.status_code == 403 and auto_connect: + elif r.status_code == 401 and auto_connect: self.connect() return self._post(op, False, json, **kwargs) else: -- GitLab