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

Authorize when calling endpoints

parent 2887d5e6
......@@ -29,10 +29,16 @@ class Endpoints:
class TopDeskClient:
def __init__(self, url, headers=None, rewrite_url=None):
def __init__(self,
url,
username,
password,
headers=None,
rewrite_url=None):
self.urls = Endpoints(url)
self.rewrite_url = rewrite_url
self.headers = headers
self.auth = requests.auth.HTTPBasicAuth(username, password)
def _build_headers(self, headers):
request_headers = {}
......@@ -56,6 +62,7 @@ class TopDeskClient:
r = requests.request(method_name,
(url if self.rewrite_url is None
else url.replace(*self.rewrite_url)),
auth=self.auth,
headers=(None if headers is None else
self._build_headers(headers)),
params=params if params is not None else {},
......
Supports Markdown
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