diff --git a/eufy_security/api.py b/eufy_security/api.py index a87b32a..5c7f54d 100644 --- a/eufy_security/api.py +++ b/eufy_security/api.py @@ -19,6 +19,7 @@ class API: def __init__(self, email: str, password: str, websession: ClientSession) -> None: """Initialize.""" + self._api_base: str = API_BASE self._email: str = email self._password: str = password self._retry_on_401: bool = False @@ -41,6 +42,10 @@ async def async_authenticate(self) -> None: self._token_expiration = datetime.fromtimestamp( auth_resp["data"]["token_expires_at"] ) + domain = auth_resp["data"].get("domain") + if domain: + self._api_base = f"https://{domain}/v1" + _LOGGER.info(f"Switching to another API_BASE: {self._api_base}") async def async_get_history(self) -> dict: """Get the camera's history.""" @@ -76,7 +81,7 @@ async def request( self._token_expiration = None await self.async_authenticate() - url: str = f"{API_BASE}/{endpoint}" + url: str = f"{self._api_base}/{endpoint}" if not headers: headers = {}