Skip to content
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
24 changes: 14 additions & 10 deletions src/api/hive_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# pylint: skip-file
import json
import logging
import re

import requests
import urllib3
Expand All @@ -12,6 +13,11 @@

_LOGGER = logging.getLogger(__name__)

# The SSO bootstrap page embeds its config as `window.<key> = <value>`
# assignments. The value quoting changed from double to single quotes on
# 2026-10-20, so accept either (and require the closing quote to match).
_SSO_ASSIGNMENT = re.compile(r"""window\.(\w+)\s*=\s*(["'])(.*?)\2""")


class HiveApi:
"""Hive API Code."""
Expand Down Expand Up @@ -106,7 +112,7 @@ def refreshTokens(self, tokens={}):
jsc = (
"{"
+ ",".join(
('"' + str(i) + '": ' '"' + str(t) + '" ' for i, t in tokens.items())
('"' + str(i) + '": "' + str(t) + '" ' for i, t in tokens.items())
)
+ "}"
)
Expand Down Expand Up @@ -140,14 +146,12 @@ def getLoginInfo(self):
"getLoginInfo - Login info response status: %s", data.status_code
)
html = PyQuery(data.content)
json_data = json.loads(
'{"'
+ (html("script:first").text())
.replace(",", ', "')
.replace("=", '":')
.replace("window.", "")
+ "}"
)
json_data = {
key: value
for key, _quote, value in _SSO_ASSIGNMENT.findall(
html("script:first").text()
)
}

loginData = {}
loginData.update({"UPID": json_data["HiveSSOPoolId"]})
Expand Down Expand Up @@ -311,7 +315,7 @@ def setState(self, n_type, n_id, **kwargs):
jsc = (
"{"
+ ",".join(
('"' + str(i) + '": ' '"' + str(t) + '" ' for i, t in kwargs.items())
('"' + str(i) + '": "' + str(t) + '" ' for i, t in kwargs.items())
)
+ "}"
)
Expand Down
Loading