updated to use gandi PATs

Reason:
API Keys are deprecated
This commit is contained in:
Kristian Krsnik 2024-09-01 14:58:24 +02:00
parent 8e16fdebfd
commit fc0d163192
Signed by: Kristian
GPG Key ID: FD1330AC9F909E85
2 changed files with 4 additions and 4 deletions

View File

@ -18,14 +18,14 @@ It is also possible to define a path to a file with the API key written in it. T
## Usage ## 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. 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 ```json
{ {
"api": { "api": {
"<Your-API-Key>": { "<Your-PAT>": {
"example.com": [ "@", "www", "sub1" ], "example.com": [ "@", "www", "sub1" ],
"example.org": [ "@", "www", "sub1", "sub2" ] "example.org": [ "@", "www", "sub1", "sub2" ]
}, },

View File

@ -120,7 +120,7 @@ def checkRecords(api: dict[str, dict[str, list[str]]], current_ip: str, log: Cal
records_to_renew = api records_to_renew = api
for key, domains in api.items(): for key, domains in api.items():
headers = {'authorization': f"Apikey {key}"} headers = {'Authorization': f"Bearer {key}"}
for domain, _ in domains.items(): for domain, _ in domains.items():
response = requests.get( 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(): for api_key, domains in api.items():
headers = { headers = {
'authorization': f"Apikey {api_key}", 'Authorization': f"Bearer {api_key}",
'content-type': 'application/json', 'content-type': 'application/json',
} }