Add content type to header to fix downloading

This commit is contained in:
Kevin Fronczak
2021-02-05 15:11:03 +00:00
parent f6118ea4a7
commit ec67d97809
+8 -1
View File
@@ -58,7 +58,11 @@ class Auth:
"""Return authorization header.""" """Return authorization header."""
if self.token is None: if self.token is None:
return 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): def create_session(self, opts=None):
"""Create a session for blink communication.""" """Create a session for blink communication."""
@@ -227,6 +231,9 @@ class Auth:
try: try:
json_resp = response.json() json_resp = response.json()
blink.available = json_resp["valid"] blink.available = json_resp["valid"]
if not json_resp["valid"]:
_LOGGER.error(f"{json_resp['message']}")
return False
except (KeyError, TypeError): except (KeyError, TypeError):
_LOGGER.error("Did not receive valid response from server.") _LOGGER.error("Did not receive valid response from server.")
return False return False