From 3dc4948396a6f97c4fb5a0679481f7b939a7b25c Mon Sep 17 00:00:00 2001 From: mkmer Date: Sun, 14 Jan 2024 17:06:39 +0000 Subject: [PATCH] Add notification key to login --- blinkpy/api.py | 4 ++++ blinkpy/auth.py | 3 +++ tests/test_auth.py | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/blinkpy/api.py b/blinkpy/api.py index 82485dad..c74f970e 100644 --- a/blinkpy/api.py +++ b/blinkpy/api.py @@ -22,6 +22,7 @@ async def request_login( auth, url, login_data, + notification_key, is_retry=False, ): """ @@ -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"], diff --git a/blinkpy/auth.py b/blinkpy/auth.py index 250a081a..ae57be6a 100644 --- a/blinkpy/auth.py +++ b/blinkpy/auth.py @@ -29,6 +29,7 @@ def __init__( session=None, agent=DEFAULT_USER_AGENT, app_build=APP_BUILD, + notificaiton_key=None, ): """ Initialize auth handler. @@ -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): @@ -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: diff --git a/tests/test_auth.py b/tests/test_auth.py index 0d6168e9..e8e38622 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -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."""