Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Switch to proper region (#20)
Browse files Browse the repository at this point in the history
* Switch to proper region

* Correct the endpoint
  • Loading branch information
nonsleepr authored and bachya committed Dec 12, 2019
1 parent bf0f810 commit 249f0fd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion eufy_security/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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."""
Expand Down Expand Up @@ -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 = {}
Expand Down

0 comments on commit 249f0fd

Please sign in to comment.