Skip to content

Commit

Permalink
Fix auth for newer firmwares
Browse files Browse the repository at this point in the history
  • Loading branch information
rroller committed Sep 16, 2023
1 parent 98ebf6a commit 012a843
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions custom_components/netgear_wax/client_wax.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,18 @@ async def async_login(self):
response.raise_for_status()
_LOGGER.debug("login security token response=%s", await response.text())

# Older firmwares use a response header
security_token = response.headers.get("security")

# Newer firmewares return a security token in the response
text = ""
if security_token is None:
text = await response.text()
result = json.loads(text)
if "system" in result and "security_token" in result["system"]:
security_token = result["system"]["security_token"]

if security_token is None:
raise Exception("Could not get security token: " + text)

# TODO: is python thread safe? I have no idea. If not, we should guard when settings these two values
Expand Down

0 comments on commit 012a843

Please sign in to comment.