Commit da0a42c3 authored by Jo Sama's avatar Jo Sama 😱
Browse files

Fix headers and autentication

parent f73c50a5
......@@ -71,14 +71,17 @@ class Endpoints:
class TopDeskClient:
def __init__(self,
url,
username,
password,
username=None,
password=None,
headers={},
rewrite_url=None):
self.urls = Endpoints(url)
self.rewrite_url = rewrite_url
self.headers = headers
self.auth = requests.auth.HTTPBasicAuth(username, password)
if username and password:
self.auth = requests.auth.HTTPBasicAuth(username, password)
else:
self.auth = None
def _build_headers(self, headers):
request_headers = {}
......@@ -103,7 +106,7 @@ class TopDeskClient:
(url if self.rewrite_url is None
else url.replace(*self.rewrite_url)),
auth=self.auth,
headers=(None if headers is None else
headers=(self._build_headers({}) if headers is None else
self._build_headers(headers)),
params=params if params is not None else {},
**kwargs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment