Improve broker read auth diagnostics

This commit is contained in:
Codex
2026-05-08 10:22:00 +08:00
parent 0c7efd4e5e
commit 00b7e08cda
@@ -203,18 +203,27 @@ class BrokerReadModelService:
client_kwargs["proxy"] = self.proxy_url
client_kwargs["trust_env"] = False
with httpx.Client(**client_kwargs) as client:
response = client.get(
f"{self.base_url}{path}",
params=params,
headers={
"OK-ACCESS-KEY": api_key,
"OK-ACCESS-SIGN": signature,
"OK-ACCESS-TIMESTAMP": timestamp,
"OK-ACCESS-PASSPHRASE": api_passphrase,
"Content-Type": "application/json",
},
)
response.raise_for_status()
try:
response = client.get(
f"{self.base_url}{path}",
params=params,
headers={
"OK-ACCESS-KEY": api_key,
"OK-ACCESS-SIGN": signature,
"OK-ACCESS-TIMESTAMP": timestamp,
"OK-ACCESS-PASSPHRASE": api_passphrase,
"Content-Type": "application/json",
},
)
response.raise_for_status()
except httpx.HTTPStatusError as exc:
body = exc.response.text
try:
payload = exc.response.json()
body = f"{payload.get('code')}:{payload.get('msg')}" if isinstance(payload, dict) else body
except Exception:
pass
raise ValueError(f"okx_read_http_{exc.response.status_code}:{body}") from exc
payload = response.json()
if not isinstance(payload, dict):
raise ValueError("okx_read_invalid_payload")