@@ -95,6 +95,9 @@ def __init__(self, access_token=None, **kwargs):
9595 cache_options ["ttl" ] = CACHE_TTL
9696 self .cache = DefaultCache (** cache_options )
9797
98+ # setup custom headers
99+ self .headers = kwargs .get ("headers" , None )
100+
98101 def getDetails (self , ip_address = None , timeout = None ):
99102 """
100103 Get details for specified IP address as a Details object.
@@ -133,7 +136,7 @@ def getDetails(self, ip_address=None, timeout=None):
133136 url = API_URL
134137 if ip_address :
135138 url += "/" + ip_address
136- headers = handler_utils .get_headers (self .access_token )
139+ headers = handler_utils .get_headers (self .access_token , self . headers )
137140 response = requests .get (url , headers = headers , ** req_opts )
138141 if response .status_code == 429 :
139142 raise RequestQuotaExceededError ()
@@ -226,7 +229,7 @@ def getBatchDetails(
226229
227230 # loop over batch chunks and do lookup for each.
228231 url = API_URL + "/batch"
229- headers = handler_utils .get_headers (self .access_token )
232+ headers = handler_utils .get_headers (self .access_token , self . headers )
230233 headers ["content-type" ] = "application/json"
231234 for i in range (0 , len (lookup_addresses ), batch_size ):
232235 # quit if total timeout is reached.
@@ -295,7 +298,7 @@ def getMap(self, ips):
295298
296299 req_opts = {** self .request_options }
297300 url = f"{ API_URL } /map?cli=1"
298- headers = handler_utils .get_headers (None )
301+ headers = handler_utils .get_headers (None , self . headers )
299302 headers ["content-type" ] = "application/json"
300303 response = requests .post (
301304 url , json = ip_strs , headers = headers , ** req_opts
0 commit comments