Skip to content

Commit

Permalink
Version 0.7.x header update (#773)
Browse files Browse the repository at this point in the history
* Try to match arlo's backend.

- add no caching
- make sse NOT use cloudscraper
- remove schemaVersion

* Bump revision.
  • Loading branch information
twrecked authored Jul 4, 2023
1 parent a8a7602 commit 91ba0e3
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 23 deletions.
2 changes: 2 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
aarlo/pyaarlo
0.7.4b17:
Play catch up with Arlo.
0.7.4b16:
Fix auth headers.
0.7.4b15:
Expand Down
4 changes: 2 additions & 2 deletions custom_components.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"aarlo": {
"version": "0.7.4b16",
"version": "0.7.4b17",
"local_location": "/custom_components/aarlo/__init__.py",
"remote_location": "https://raw.githubusercontent.com/twrecked/hass-aarlo/master/custom_components/aarlo/__init__.py",
"visit_repo": "https://github.com/twrecked/hass-aarlo",
Expand All @@ -18,7 +18,7 @@
]
},
"pyaarlo": {
"version": "0.7.4b16",
"version": "0.7.4b17",
"local_location": "/custom_components/aarlo/pyaarlo/__init__.py",
"remote_location": "https://raw.githubusercontent.com/twrecked/hass-aarlo/master/custom_components/aarlo/pyaarlo/__init__.py",
"visit_repo": "https://github.com/twrecked/hass-aarlo",
Expand Down
2 changes: 1 addition & 1 deletion custom_components/aarlo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
SIREN_STATE_KEY
)

__version__ = "0.7.4b16"
__version__ = "0.7.4b17"

_LOGGER = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion custom_components/aarlo/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"dependencies": ["ffmpeg"],
"codeowners": ["@twrecked"],
"requirements": ["unidecode","cloudscraper>=1.2.71", "paho-mqtt"],
"version": "0.7.4b16",
"version": "0.7.4b17",
"iot_class": "cloud_push"
}
2 changes: 1 addition & 1 deletion custom_components/aarlo/pyaarlo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

_LOGGER = logging.getLogger("pyaarlo")

__version__ = "0.7.4b16"
__version__ = "0.7.4b17"


class PyArlo(object):
Expand Down
54 changes: 36 additions & 18 deletions custom_components/aarlo/pyaarlo/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ def _sse_main(self):
self._event_client = SSEClient(
self._arlo,
self._arlo.cfg.host + SUBSCRIBE_PATH,
session=self._session,
headers=self._headers(),
reconnect_cb=self._sse_reconnected,
)
else:
Expand All @@ -533,7 +533,7 @@ def _sse_main(self):
self._event_client = SSEClient(
self._arlo,
self._arlo.cfg.host + SUBSCRIBE_PATH,
session=self._session,
headers=self._headers(),
reconnect_cb=self._sse_reconnected,
timeout=self._arlo.cfg.stream_timeout,
)
Expand Down Expand Up @@ -646,13 +646,43 @@ def _auth_headers(self):
"Accept": "application/json, text/plain, */*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-GB,en;q=0.9,en-US;q=0.8",
"Cache-Control": "no-cache",
"Origin": ORIGIN_HOST,
"Pragma": "no-cache",
"Referer": REFERER_HOST,
# "Sec-Ch-Ua": '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
# "Sec-Ch-Ua-Mobile": "?0",
# "Sec-Ch-Ua-Platform": "Linux",
# "Sec-Fetch-Dest": "empty",
# "Sec-Fetch-Mode": "cors",
# "Sec-Fetch-Site": "same-site",
"Source": "arloCamWeb",
"User-Agent": self._user_agent,
"x-user-device-id": self._user_device_id,
"x-user-device-automation-name": "QlJPV1NFUg==",
"x-user-device-type": "BROWSER",
"X-User-Device-Automation-name": "QlJPV1NFUg==",
"X-User-Device-Id": self._user_device_id,
"X-User-Device-Type": "BROWSER",
}

def _headers(self):
return {
"Accept": "application/json",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-GB,en;q=0.9,en-US;q=0.8",
"Auth-Version": "2",
"Authorization": self._token,
"Cache-Control": "no-cache",
"Content-Type": "application/json; charset=utf-8;",
"Origin": ORIGIN_HOST,
"Pragma": "no-cache",
"Referer": REFERER_HOST,
# "SchemaVersion": "1",
# "Sec-Ch-Ua": '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
# "Sec-Ch-Ua-Mobile": "?0",
# "Sec-Ch-Ua-Platform": "Linux",
# "Sec-Fetch-Dest": "empty",
# "Sec-Fetch-Mode": "cors",
# "Sec-Fetch-Site": "same-site",
"User-Agent": self._user_agent,
}

def _auth(self):
Expand Down Expand Up @@ -834,19 +864,7 @@ def _login(self):
self._arlo.debug("newish sessions, re-using")

# update sessions headers
headers = {
"Accept": "application/json",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-GB,en;q=0.9,en-US;q=0.8",
"Auth-Version": "2",
"Authorization": self._token,
"Content-Type": "application/json; charset=utf-8;",
"Origin": ORIGIN_HOST,
"Pragma": "no-cache",
"Referer": REFERER_HOST,
"SchemaVersion": "1",
"User-Agent": self._user_agent,
}
headers = self._headers()
self._session.headers.update(headers)

# Grab a session. Needed for new session and used to check existing
Expand Down

0 comments on commit 91ba0e3

Please sign in to comment.