Make logout actually work, fixes #5

main
Mark Cotton 2023-09-06 21:30:10 -05:00
parent 0ebdbbe103
commit 2d1a76b9ff
1 changed files with 7 additions and 9 deletions

View File

@ -1,5 +1,5 @@
""" Python client for Eagle Eye Networks APIv3 """ """ Python client for Eagle Eye Networks APIv3 """
version = "0.0.19" version = "0.0.20"
__version__ = version __version__ = version
@ -183,15 +183,13 @@ class EagleEyev3():
"token_type_hint": "access_token" "token_type_hint": "access_token"
} }
headers = { headers = {
"Authorization": f"Bearer {self.access_token}", "Content-type": "application/x-www-form-urlencoded"
"Accept": "application/json",
"Content-type": "application/json"
} }
# Send a POST request to obtain the base URL # Send a POST request to obtain the base URL
response = requests.post(url, json=payload, headers=headers, timeout=self._get_timeout_values('logout')) response = requests.post(url, auth=(self.client_id, self.client_secret), data=payload, headers=headers, timeout=self._get_timeout_values('logout'))
response_json = response.json() response_text = response.text
logging.info(f"{response.status_code} in logout") logging.info(f"{response.status_code} in logout")
@ -199,7 +197,7 @@ class EagleEyev3():
success = True success = True
else: else:
success = False success = False
logging.info(f"call to logout: {response_json}") logging.info(f"call to logout: {response.status_code}")
self.access_token = None self.access_token = None
self.refresh_token = None self.refresh_token = None
@ -207,7 +205,7 @@ class EagleEyev3():
return { return {
"success": success, "success": success,
"response_http_status": response.status_code, "response_http_status": response.status_code,
"data": response_json "data": response_text
} }
def login_from_reseller(self, target_account_id=None, cascade=True): def login_from_reseller(self, target_account_id=None, cascade=True):