Add support for new API tokens.

This commit is contained in:
Han Zhang
2020-07-27 15:27:55 -04:00
parent 66bbbb5295
commit 022da2958a
5 changed files with 59 additions and 25 deletions

View File

@@ -83,11 +83,17 @@ def commitRecord(ip):
def cf_api(endpoint, method, config, headers={}, data=False):
headers = {
"X-Auth-Email": config['account_email'],
"X-Auth-Key": config['api_key'],
**headers
}
api_token = config['authentication']['api_token']
if api_token != '' and api_token != 'api_token_here':
headers = {
"Authorization": "Bearer " + config['authentication']['api_token'],
**headers
}
else:
headers = {
"X-Auth-Email": config['authentication']['api_key']['account_email'],
"X-Auth-Key": config['authentication']['api_key']['api_key'],
}
if(data == False):
response = requests.request(
@@ -98,7 +104,6 @@ def cf_api(endpoint, method, config, headers={}, data=False):
return response.json()
for ip in getIPs():
print("Checking " + ip["type"] + " records")
commitRecord(ip)