File tree 5 files changed +29
-13
lines changed
5 files changed +29
-13
lines changed Original file line number Diff line number Diff line change @@ -4,10 +4,18 @@ Changelog
4
4
5
5
A list of changes between each release
6
6
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
+
7
15
0.16.1 (2020-07-29)
8
16
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9
17
10
- - Unpin requeirements , set minimum version instead
18
+ - Unpin requirements , set minimum version instead
11
19
- Bump coverage to 5.2.1
12
20
- Bump pytest to 6.0.0
13
21
Original file line number Diff line number Diff line change 3
3
import logging
4
4
from json import dumps
5
5
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
7
7
8
8
_LOGGER = logging .getLogger (__name__ )
9
9
@@ -20,21 +20,24 @@ def request_login(
20
20
:param url: Login url.
21
21
:login_data: Dictionary containing blink login data.
22
22
"""
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
+ }
24
29
data = dumps (
25
30
{
26
31
"email" : login_data ["username" ],
27
32
"password" : login_data ["password" ],
28
33
"notification_key" : login_data ["notification_key" ],
29
34
"unique_id" : login_data ["uid" ],
30
- "app_version" : "6.0.7 (520300) #afb0be72a" ,
31
35
"device_identifier" : login_data ["device_id" ],
32
36
"client_name" : "Computer" ,
33
- "client_type" : "android" ,
34
- "os_version" : "5.1.1" ,
35
37
"reauth" : "false" ,
36
38
}
37
39
)
40
+
38
41
return auth .query (
39
42
url = url ,
40
43
headers = headers ,
Original file line number Diff line number Diff line change @@ -108,11 +108,7 @@ def refresh_token(self):
108
108
try :
109
109
_LOGGER .info ("Token expired, attempting automatic refresh." )
110
110
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 ()
116
112
self .is_errored = False
117
113
except LoginError :
118
114
_LOGGER .error ("Login endpoint failed. Try again later." )
@@ -122,6 +118,14 @@ def refresh_token(self):
122
118
raise TokenRefreshFailed
123
119
return True
124
120
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
+
125
129
def startup (self ):
126
130
"""Initialize tokens for communication."""
127
131
self .validate_login ()
Original file line number Diff line number Diff line change 4
4
5
5
MAJOR_VERSION = 0
6
6
MINOR_VERSION = 16
7
- PATCH_VERSION = 1
7
+ PATCH_VERSION = 2
8
8
9
9
__version__ = f"{ MAJOR_VERSION } .{ MINOR_VERSION } .{ PATCH_VERSION } "
10
10
58
58
"""
59
59
OTHER
60
60
"""
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"
61
62
DEVICE_ID = "Blinkpy"
62
63
TIMESTAMP_FORMAT = "%Y-%m-%dT%H:%M:%S%z"
63
64
DEFAULT_MOTION_INTERVAL = 1
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ flake8-docstrings==1.5.0
5
5
pre-commit==2.6.0
6
6
pylint==2.5.3
7
7
pydocstyle==5.0.2
8
- pytest==6.0.0
8
+ pytest==6.0.1
9
9
pytest-cov==2.10.0
10
10
pytest-sugar==0.9.4
11
11
pytest-timeout==1.4.2
You can’t perform that action at this time.
0 commit comments