Skip to content

Commit

Permalink
Merge pull request #860 from mkmer/optional-agent
Browse files Browse the repository at this point in the history
Add option to change agent from Auth() init
  • Loading branch information
fronzbot authored Jan 13, 2024
2 parents 5d83708 + ec8f682 commit c899cf4
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions blinkpy/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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):
Expand All @@ -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",
}

Expand Down

0 comments on commit c899cf4

Please sign in to comment.