From fc0d16319209b4e987b5d85deffddac045866591 Mon Sep 17 00:00:00 2001 From: Kristian Krsnik Date: Sun, 1 Sep 2024 14:58:24 +0200 Subject: [PATCH] updated to use gandi PATs Reason: API Keys are deprecated --- README.md | 4 ++-- src/main.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a31a574..f3889ed 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,14 @@ It is also possible to define a path to a file with the API key written in it. T ## Usage -First, get your API key from https://account.gandi.net/en/users/USER/security where `USER` is your Gandi username. +First, get your Personal Access Token (PAT) from https://account.gandi.net/en/users/USER/security where `USER` is your Gandi username. The script looks for a config file at `$HOME/.config/dyn-gandi/config.log` or `/etc/dyn-gandi.conf` in that order. So create a file at one of these locations according to the schema below. ```json { "api": { - "": { + "": { "example.com": [ "@", "www", "sub1" ], "example.org": [ "@", "www", "sub1", "sub2" ] }, diff --git a/src/main.py b/src/main.py index cb8044b..21b8560 100644 --- a/src/main.py +++ b/src/main.py @@ -120,7 +120,7 @@ def checkRecords(api: dict[str, dict[str, list[str]]], current_ip: str, log: Cal records_to_renew = api for key, domains in api.items(): - headers = {'authorization': f"Apikey {key}"} + headers = {'Authorization': f"Bearer {key}"} for domain, _ in domains.items(): response = requests.get( @@ -159,7 +159,7 @@ def renewRecords(api: dict[str, dict[str, list[str]]], current_ip: str, log: Cal for api_key, domains in api.items(): headers = { - 'authorization': f"Apikey {api_key}", + 'Authorization': f"Bearer {api_key}", 'content-type': 'application/json', }