Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to change agent from Auth() init #860

Merged
merged 1 commit into from
Jan 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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