@@ -67,7 +67,8 @@ def __init__(self, domain, realm, consumer_key, consumer_secret,
6767 email = None ,
6868 password = None ,
6969 http_proxy = None ,
70- https_proxy = None ):
70+ https_proxy = None ,
71+ headers = {}):
7172 """
7273
7374 domain -- Your UI domain. The API is accessed off this domain.
@@ -81,6 +82,7 @@ def __init__(self, domain, realm, consumer_key, consumer_secret,
8182 authorization_url -- Only override for debugging.
8283 api_path -- Only override for debugging.
8384 http_proxy -- Optional proxy to send HTTP requests through.
85+ headers -- list of headers to send with the request
8486 """
8587
8688 self .domain = domain
@@ -92,6 +94,7 @@ def __init__(self, domain, realm, consumer_key, consumer_secret,
9294 self .access_token_url = access_token_url
9395 self .authorization_url = authorization_url
9496 self .api_path = api_path
97+ self .headers = headers
9598
9699 # Validate API path:
97100 if api_path not in ACCEPTABLE_PATHS :
@@ -167,6 +170,7 @@ def request(self, url, method='GET', headers={}, data=None, sign=False,
167170 if method in ('POST' , 'PUT' ) and not data :
168171 data = ''
169172
173+ headers = headers or self .headers
170174 # If we're sending a JSON blob, we need to specify the header:
171175 if method in ('POST' , 'PUT' ) and send_json :
172176 headers ['Content-Type' ] = 'application/json'
0 commit comments