fix: fix service key validation in OSS

Fixes #303
This commit is contained in:
Abhishek Kumar 2026-05-28 08:08:59 +05:30
parent 7eecadd8d6
commit 21e7fd8d78
2 changed files with 101 additions and 8 deletions

View file

@ -263,10 +263,12 @@ class MPSServiceKeyClient:
HTTPException: If the API call fails
"""
async with httpx.AsyncClient(timeout=self.timeout) as client:
response = await client.post(
f"{self.base_url}/api/v1/service-keys/usage",
json={"service_key": service_key},
headers=self._get_headers(organization_id, created_by),
response = await client.get(
f"{self.base_url}/api/v1/service-keys/usage/self",
headers={
"Authorization": f"Bearer {service_key}",
"Content-Type": "application/json",
},
)
if response.status_code == 200:
@ -429,10 +431,12 @@ class MPSServiceKeyClient:
"""
try:
with httpx.Client(timeout=self.timeout) as client:
response = client.post(
f"{self.base_url}/api/v1/service-keys/usage",
json={"service_key": service_key},
headers=self._get_headers(organization_id, created_by),
response = client.get(
f"{self.base_url}/api/v1/service-keys/usage/self",
headers={
"Authorization": f"Bearer {service_key}",
"Content-Type": "application/json",
},
)
return response.status_code == 200
except Exception: