Skip to content

Commit

Permalink
Also try the old API key authentication method if the PAT one is reje…
Browse files Browse the repository at this point in the history
…cted
  • Loading branch information
Danamir committed May 2, 2024
1 parent a3b4e88 commit a3f8cb3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions livedns_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ def _query_api(self, method, query, json_data=None):
# request
try:
r = requests.request(method=method, url=url, headers=headers, json=json_data, timeout=60.0)
if r.status_code == 403:
# on reject, also try the old API key authentication method
headers["Authorization"] = headers.get("Authorization").replace("Bearer", "Apikey")
if self.debug:
print("Requests: method=%s url=%s headers=%s json=%s" % (method, url, headers, json_data))
r = requests.request(method=method, url=url, headers=headers, json=json_data, timeout=60.0)
except Timeout:
if self.debug:
print("Timeout error.")
Expand Down

0 comments on commit a3f8cb3

Please sign in to comment.