Skip to content
Snippets Groups Projects
Commit ab353b70 authored by onbpre's avatar onbpre
Browse files

Replace all HTTP 403 codes with 401 codes for more appropriate authorization handling

parent 5f4b3b05
Branches master
No related tags found
No related merge requests found
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment