diff --git a/docs/widgets/services/kavita.md b/docs/widgets/services/kavita.md index 12d40164a..af5d1c224 100644 --- a/docs/widgets/services/kavita.md +++ b/docs/widgets/services/kavita.md @@ -15,4 +15,5 @@ widget: url: http://kavita.host.or.ip:port username: username password: password + key: kavitaapikey # Optional, e.g. if not using username and password ``` diff --git a/src/widgets/kavita/proxy.js b/src/widgets/kavita/proxy.js index 1c41c45f1..af29d048a 100644 --- a/src/widgets/kavita/proxy.js +++ b/src/widgets/kavita/proxy.js @@ -14,7 +14,13 @@ async function login(widget, service) { const endpoint = "Account/login"; const api = widgets?.[widget.type]?.api; const loginUrl = new URL(formatApiCall(api, { endpoint, ...widget })); - const loginBody = { username: widget.username, password: widget.password }; + const loginBody = {}; + if (widget.username && widget.password) { + loginBody.username = widget.username; + loginBody.password = widget.password; + } else if (widget.key) { + loginBody.apiKey = widget.key; + } const headers = { "Content-Type": "application/json", accept: "text/plain" }; const [, , data] = await httpProxy(loginUrl, {