feat(gandi_livedns): support personal access tokens (#8337)

* fix(gandi_livedns): fix unsafe conditionals in tests

* feat(gandi_livedns): support personal access tokens

Fixes #7639
This commit is contained in:
Gilbert Gilb's 2024-05-18 15:42:11 +02:00 committed by GitHub
parent bb73f28bf5
commit a409f8fc2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 69 additions and 27 deletions

View file

@ -33,6 +33,7 @@ class GandiLiveDNSAPI(object):
def __init__(self, module):
self.module = module
self.api_key = module.params['api_key']
self.personal_access_token = module.params['personal_access_token']
def _build_error_message(self, module, info):
s = ''
@ -50,7 +51,12 @@ class GandiLiveDNSAPI(object):
return s
def _gandi_api_call(self, api_call, method='GET', payload=None, error_on_404=True):
headers = {'Authorization': 'Apikey {0}'.format(self.api_key),
authorization_header = (
'Bearer {0}'.format(self.personal_access_token)
if self.personal_access_token
else 'Apikey {0}'.format(self.api_key)
)
headers = {'Authorization': authorization_header,
'Content-Type': 'application/json'}
data = None
if payload: