Adopt the new bearer auth for PATs

This commit is contained in:
Reid 'arrdem' McKenzie 2024-05-13 22:41:38 -06:00
parent 1ad35f95f1
commit 7fe1b0b44d

View file

@ -20,7 +20,7 @@ class GandiAPI(object):
""" """
def __init__(self, key=None, use_cache=True): def __init__(self, key: str, use_cache: bool =True):
self._base = "https://dns.api.gandi.net/api/v5" self._base = "https://dns.api.gandi.net/api/v5"
self._key = key self._key = key
self._use_cache = use_cache self._use_cache = use_cache
@ -30,7 +30,7 @@ class GandiAPI(object):
def _do_request(self, method, path, headers=None, **kwargs): def _do_request(self, method, path, headers=None, **kwargs):
headers = headers or {} headers = headers or {}
headers["X-Api-Key"] = self._key headers["Authorization"] = "Bearer " + self._key
resp = method(self._base + path, headers=headers, **kwargs) resp = method(self._base + path, headers=headers, **kwargs)
if resp.status_code > 299: if resp.status_code > 299:
print(resp.text) print(resp.text)