Skip to content

Commit 1839bc3

Browse files
ry-opsclaude
andcommitted
Fix cloud API auth: use X-API-Key header instead of Authorization
UniFi Site Manager API requires X-API-Key header, not Authorization. This was causing cloud API calls to fail authentication. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1e4350a commit 1839bc3

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

main.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ def try_get_protect(label: str, path: str):
767767

768768
# Site Manager
769769
if SM_BASE and SM_TOKEN:
770-
try_get("sitemanager.root", f"{SM_BASE}/", {"Authorization": SM_TOKEN})
770+
try_get("sitemanager.root", f"{SM_BASE}/", {"X-API-Key": SM_TOKEN})
771771
else:
772772
out["sitemanager.info"] = "Set UNIFI_SITEMGR_BASE & UNIFI_SITEMGR_TOKEN to probe."
773773

@@ -1287,12 +1287,11 @@ def list_hosts_cloud(page_size: int = 100) -> Dict[str, Any]:
12871287
try:
12881288
headers = {
12891289
"Accept": "application/json",
1290-
"Authorization": SM_TOKEN,
1291-
"Content-Type": "application/json"
1290+
"X-API-Key": SM_TOKEN,
12921291
}
1293-
1292+
12941293
params = {"limit": page_size}
1295-
1294+
12961295
url = f"{SM_BASE}/v1/hosts"
12971296
validated_url = validate_url(url, "cloud hosts list")
12981297

0 commit comments

Comments
 (0)