From ec8f6825a8efd5331719a9d1c47339c35a2d9919 Mon Sep 17 00:00:00 2001 From: mkmer Date: Sat, 13 Jan 2024 14:32:00 +0000 Subject: [PATCH] Add option to change agent --- blinkpy/auth.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/blinkpy/auth.py b/blinkpy/auth.py index 38cb86f4..250a081a 100644 --- a/blinkpy/auth.py +++ b/blinkpy/auth.py @@ -22,7 +22,14 @@ class Auth: """Class to handle login communication.""" - def __init__(self, login_data=None, no_prompt=False, session=None): + def __init__( + self, + login_data=None, + no_prompt=False, + session=None, + agent=DEFAULT_USER_AGENT, + app_build=APP_BUILD, + ): """ Initialize auth handler. @@ -44,10 +51,9 @@ def __init__(self, login_data=None, no_prompt=False, session=None): self.login_response = None self.is_errored = False self.no_prompt = no_prompt - if session: - self.session = session - else: - self.session = ClientSession() + self._agent = agent + self._app_build = app_build + self.session = session if session else ClientSession() @property def login_attributes(self): @@ -65,9 +71,9 @@ def header(self): if self.token is None: return None return { - "APP-BUILD": APP_BUILD, + "APP-BUILD": self._app_build, "TOKEN_AUTH": self.token, - "User-Agent": DEFAULT_USER_AGENT, + "User-Agent": self._agent, "Content-Type": "application/json", }