Merge pull request #424 from fronzbot/fix-vid-download

Add content type to header to fix downloading
This commit is contained in:
Kevin Fronczak
2021-02-05 10:21:10 -05:00
committed by GitHub
2 changed files with 13 additions and 2 deletions
+8 -1
View File
@@ -58,7 +58,11 @@ class Auth:
"""Return authorization header."""
if self.token is None:
return None
return {"TOKEN_AUTH": self.token, "user-agent": DEFAULT_USER_AGENT}
return {
"TOKEN_AUTH": self.token,
"user-agent": DEFAULT_USER_AGENT,
"content-type": "application/json",
}
def create_session(self, opts=None):
"""Create a session for blink communication."""
@@ -227,6 +231,9 @@ class Auth:
try:
json_resp = response.json()
blink.available = json_resp["valid"]
if not json_resp["valid"]:
_LOGGER.error(f"{json_resp['message']}")
return False
except (KeyError, TypeError):
_LOGGER.error("Did not receive valid response from server.")
return False
+5 -1
View File
@@ -128,7 +128,11 @@ class TestAuth(unittest.TestCase):
def test_header(self):
"""Test header data."""
self.auth.token = "bar"
expected_header = {"TOKEN_AUTH": "bar", "user-agent": const.DEFAULT_USER_AGENT}
expected_header = {
"TOKEN_AUTH": "bar",
"user-agent": const.DEFAULT_USER_AGENT,
"content-type": "application/json",
}
self.assertDictEqual(self.auth.header, expected_header)
def test_header_no_token(self):