fix: authenticate MoviePilot REST requests with token query
这个提交存在于:
父节点
d03097d513
当前提交
7851dc2418
共有 2 个文件被更改,包括 4 次插入 和 1 次删除
|
|
@ -121,11 +121,13 @@ class MoviePilotClient:
|
||||||
await self.start()
|
await self.start()
|
||||||
assert self._client is not None
|
assert self._client is not None
|
||||||
request_path = path if path.startswith("/") else f"/{path}"
|
request_path = path if path.startswith("/") else f"/{path}"
|
||||||
|
request_params = dict(params or {})
|
||||||
|
request_params.setdefault("token", self._api_token)
|
||||||
try:
|
try:
|
||||||
response = await self._client.request(
|
response = await self._client.request(
|
||||||
method,
|
method,
|
||||||
request_path,
|
request_path,
|
||||||
params=params,
|
params=request_params,
|
||||||
json=json,
|
json=json,
|
||||||
)
|
)
|
||||||
except httpx.TimeoutException as exc:
|
except httpx.TimeoutException as exc:
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ async def test_request_adds_api_header_and_unwraps_data() -> None:
|
||||||
async def handler(request: httpx.Request) -> httpx.Response:
|
async def handler(request: httpx.Request) -> httpx.Response:
|
||||||
assert request.headers["X-API-KEY"] == "secret"
|
assert request.headers["X-API-KEY"] == "secret"
|
||||||
assert request.url.path == "/api/v1/media/search"
|
assert request.url.path == "/api/v1/media/search"
|
||||||
|
assert request.url.params["token"] == "secret"
|
||||||
assert request.url.params["title"] == "沙丘"
|
assert request.url.params["title"] == "沙丘"
|
||||||
return httpx.Response(200, json={"success": True, "data": [{"id": 1}]})
|
return httpx.Response(200, json={"success": True, "data": [{"id": 1}]})
|
||||||
|
|
||||||
|
|
|
||||||
正在加载…
添加表格
在新工单中引用