Skip to content

Commit 6bd8d14

Browse files
authored
Merge pull request #359 from fronzbot/dev
0.16.2
2 parents f6ddfbe + 1790c1b commit 6bd8d14

File tree

5 files changed

+29
-13
lines changed

5 files changed

+29
-13
lines changed

Diff for: CHANGES.rst

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,18 @@ Changelog
44

55
A list of changes between each release
66

7+
0.16.2 (2020-08-01)
8+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9+
10+
- Add user-agent to header at login
11+
- Remove extra data parameters at login (not-needed)
12+
- Bump pytest to 6.0.1
13+
14+
715
0.16.1 (2020-07-29)
816
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
917

10-
- Unpin requeirements, set minimum version instead
18+
- Unpin requirements, set minimum version instead
1119
- Bump coverage to 5.2.1
1220
- Bump pytest to 6.0.0
1321

Diff for: blinkpy/api.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44
from json import dumps
55
from blinkpy.helpers.util import get_time, Throttle
6-
from blinkpy.helpers.constants import DEFAULT_URL, TIMEOUT
6+
from blinkpy.helpers.constants import DEFAULT_URL, TIMEOUT, DEFAULT_USER_AGENT
77

88
_LOGGER = logging.getLogger(__name__)
99

@@ -20,21 +20,24 @@ def request_login(
2020
:param url: Login url.
2121
:login_data: Dictionary containing blink login data.
2222
"""
23-
headers = {"Host": DEFAULT_URL, "Content-Type": "application/json"}
23+
headers = {
24+
"Host": DEFAULT_URL,
25+
"Content-Type": "application/json",
26+
"Accept": "/",
27+
"user-agent": DEFAULT_USER_AGENT,
28+
}
2429
data = dumps(
2530
{
2631
"email": login_data["username"],
2732
"password": login_data["password"],
2833
"notification_key": login_data["notification_key"],
2934
"unique_id": login_data["uid"],
30-
"app_version": "6.0.7 (520300) #afb0be72a",
3135
"device_identifier": login_data["device_id"],
3236
"client_name": "Computer",
33-
"client_type": "android",
34-
"os_version": "5.1.1",
3537
"reauth": "false",
3638
}
3739
)
40+
3841
return auth.query(
3942
url=url,
4043
headers=headers,

Diff for: blinkpy/auth.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,7 @@ def refresh_token(self):
108108
try:
109109
_LOGGER.info("Token expired, attempting automatic refresh.")
110110
self.login_response = self.login()
111-
self.region_id = self.login_response["region"]["tier"]
112-
self.host = f"{self.region_id}.{BLINK_URL}"
113-
self.token = self.login_response["authtoken"]["authtoken"]
114-
self.client_id = self.login_response["client"]["id"]
115-
self.account_id = self.login_response["account"]["id"]
111+
self.extract_login_info()
116112
self.is_errored = False
117113
except LoginError:
118114
_LOGGER.error("Login endpoint failed. Try again later.")
@@ -122,6 +118,14 @@ def refresh_token(self):
122118
raise TokenRefreshFailed
123119
return True
124120

121+
def extract_login_info(self):
122+
"""Extract login info from login response."""
123+
self.region_id = self.login_response["region"]["tier"]
124+
self.host = f"{self.region_id}.{BLINK_URL}"
125+
self.token = self.login_response["authtoken"]["authtoken"]
126+
self.client_id = self.login_response["client"]["id"]
127+
self.account_id = self.login_response["account"]["id"]
128+
125129
def startup(self):
126130
"""Initialize tokens for communication."""
127131
self.validate_login()

Diff for: blinkpy/helpers/constants.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
MAJOR_VERSION = 0
66
MINOR_VERSION = 16
7-
PATCH_VERSION = 1
7+
PATCH_VERSION = 2
88

99
__version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}.{PATCH_VERSION}"
1010

@@ -58,6 +58,7 @@
5858
"""
5959
OTHER
6060
"""
61+
DEFAULT_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
6162
DEVICE_ID = "Blinkpy"
6263
TIMESTAMP_FORMAT = "%Y-%m-%dT%H:%M:%S%z"
6364
DEFAULT_MOTION_INTERVAL = 1

Diff for: requirements_test.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ flake8-docstrings==1.5.0
55
pre-commit==2.6.0
66
pylint==2.5.3
77
pydocstyle==5.0.2
8-
pytest==6.0.0
8+
pytest==6.0.1
99
pytest-cov==2.10.0
1010
pytest-sugar==0.9.4
1111
pytest-timeout==1.4.2

0 commit comments

Comments
 (0)