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 notification key to login #862

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions blinkpy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ async def request_login(
auth,
url,
login_data,
notification_key,
is_retry=False,
):
"""
Expand All @@ -37,6 +38,9 @@ async def request_login(
"Content-Type": "application/json",
"user-agent": DEFAULT_USER_AGENT,
}
if notification_key:
headers["notification_key"] = notification_key

data = dumps(
{
"email": login_data["username"],
Expand Down
3 changes: 3 additions & 0 deletions blinkpy/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __init__(
session=None,
agent=DEFAULT_USER_AGENT,
app_build=APP_BUILD,
notificaiton_key=None,
):
"""
Initialize auth handler.
Expand All @@ -54,6 +55,7 @@ def __init__(
self._agent = agent
self._app_build = app_build
self.session = session if session else ClientSession()
self._notification_key = notificaiton_key

@property
def login_attributes(self):
Expand Down Expand Up @@ -94,6 +96,7 @@ async def login(self, login_url=LOGIN_ENDPOINT):
login_url,
self.data,
is_retry=False,
notification_key=self._notification_key,
)
try:
if response.status == 200:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TestAuth(IsolatedAsyncioTestCase):

def setUp(self):
"""Set up Login Handler."""
self.auth = Auth()
self.auth = Auth(notificaiton_key="testkey")

def tearDown(self):
"""Clean up after test."""
Expand Down