fixed client login and changed qt6 lib
This commit is contained in:
@@ -37,7 +37,7 @@ class APIClient:
|
||||
self.base_url = base_url.rstrip('/')
|
||||
self.access_token: Optional[str] = None
|
||||
self.refresh_token: Optional[str] = None
|
||||
self.client = httpx.Client(timeout=30.0)
|
||||
self.client = httpx.Client(timeout=30.0, follow_redirects=True)
|
||||
|
||||
def _headers(self) -> dict:
|
||||
"""Get request headers with auth token."""
|
||||
@@ -64,8 +64,10 @@ class APIClient:
|
||||
data = response.json()
|
||||
self.access_token = data["access_token"]
|
||||
self.refresh_token = data["refresh_token"]
|
||||
print(f"Login successful, token: {self.access_token[:50]}...")
|
||||
return True
|
||||
except httpx.HTTPError:
|
||||
except httpx.HTTPError as e:
|
||||
print(f"Login error: {e}")
|
||||
return False
|
||||
|
||||
def logout(self):
|
||||
@@ -100,7 +102,8 @@ class APIClient:
|
||||
def get_gateways(self) -> list[Gateway]:
|
||||
"""Get list of accessible gateways."""
|
||||
try:
|
||||
data = self._request("GET", "/api/gateways")
|
||||
print(f"Fetching gateways with token: {self.access_token[:30] if self.access_token else 'NONE'}...")
|
||||
data = self._request("GET", "/api/gateways/")
|
||||
return [
|
||||
Gateway(
|
||||
id=g["id"],
|
||||
@@ -113,7 +116,8 @@ class APIClient:
|
||||
)
|
||||
for g in data
|
||||
]
|
||||
except httpx.HTTPError:
|
||||
except httpx.HTTPError as e:
|
||||
print(f"Error fetching gateways: {e}")
|
||||
return []
|
||||
|
||||
def get_gateways_status(self) -> list[dict]:
|
||||
|
||||
Reference in New Issue
Block a user