diff --git a/moviepilot_client.py b/moviepilot_client.py index 05a6c30..b90ca7a 100644 --- a/moviepilot_client.py +++ b/moviepilot_client.py @@ -121,11 +121,13 @@ class MoviePilotClient: await self.start() assert self._client is not None request_path = path if path.startswith("/") else f"/{path}" + request_params = dict(params or {}) + request_params.setdefault("token", self._api_token) try: response = await self._client.request( method, request_path, - params=params, + params=request_params, json=json, ) except httpx.TimeoutException as exc: diff --git a/tests/test_moviepilot_client.py b/tests/test_moviepilot_client.py index d29b740..91256db 100644 --- a/tests/test_moviepilot_client.py +++ b/tests/test_moviepilot_client.py @@ -20,6 +20,7 @@ async def test_request_adds_api_header_and_unwraps_data() -> None: async def handler(request: httpx.Request) -> httpx.Response: assert request.headers["X-API-KEY"] == "secret" assert request.url.path == "/api/v1/media/search" + assert request.url.params["token"] == "secret" assert request.url.params["title"] == "沙丘" return httpx.Response(200, json={"success": True, "data": [{"id": 1}]})