Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Log text response #845

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions blinkpy/auth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
"""Login handler for blink."""
import logging
from aiohttp import ClientSession, ClientConnectionError, ContentTypeError
from aiohttp import (
ClientSession,
ClientConnectionError,
ContentTypeError,
ClientResponse,
)
from blinkpy import api
from blinkpy.helpers import util
from blinkpy.helpers.constants import (
Expand Down Expand Up @@ -123,7 +128,7 @@ async def startup(self):
if None in self.login_attributes.values():
await self.refresh_token()

async def validate_response(self, response, json_resp):
async def validate_response(self, response: ClientResponse, json_resp):
"""Check for valid response."""
if not json_resp:
self.is_errored = False
Expand All @@ -137,6 +142,9 @@ async def validate_response(self, response, json_resp):
json_data = await response.json()
except (AttributeError, ValueError) as error:
raise BlinkBadResponse from error
except ContentTypeError as error:
_LOGGER.warning("Got text for JSON response: %s", await response.text())
raise BlinkBadResponse from error

self.is_errored = False
return json_data
Expand Down