55import requests
66
77from logger import Logger
8- from utils import sanitize_secrets
8+ from utils import user_agent , sanitize_secrets
99from read_configs import read_configs
1010from api_v4 import api_v4
1111from api_extras import api_extras
@@ -27,6 +27,7 @@ def __init__(self, email, token, certtoken, base_url, debug, raw):
2727 self .certtoken = certtoken
2828 self .base_url = base_url
2929 self .raw = raw
30+ self .user_agent = user_agent ()
3031
3132 if debug :
3233 self .logger = Logger (debug ).getLogger ()
@@ -42,6 +43,7 @@ def call_with_no_auth(self, method,
4243 """ Cloudflare v4 API"""
4344
4445 headers = {
46+ 'User-Agent' : self .user_agent ,
4547 'Content-Type' : 'application/json'
4648 }
4749 return self ._call (method , headers ,
@@ -60,6 +62,7 @@ def call_with_auth(self, method,
6062 if self .email is '' or self .token is '' :
6163 raise CloudFlareAPIError (0 , 'no email and/or token defined' )
6264 headers = {
65+ 'User-Agent' : self .user_agent ,
6366 'X-Auth-Email' : self .email ,
6467 'X-Auth-Key' : self .token ,
6568 'Content-Type' : 'application/json'
@@ -80,6 +83,7 @@ def call_with_certauth(self, method,
8083 if self .certtoken is '' or self .certtoken is None :
8184 raise CloudFlareAPIError (0 , 'no cert token defined' )
8285 headers = {
86+ 'User-Agent' : self .user_agent ,
8387 'X-Auth-User-Service-Key' : self .certtoken ,
8488 'Content-Type' : 'application/json'
8589 }
0 commit comments