You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support qBittorrent 5.2 API-key authentication (closesManiMatter#353)
qBittorrent 5.2 added stateless API-key auth (Authorization: Bearer),
which lets users avoid storing username/password credentials. This adds
an optional `api_key` field to qBittorrent clients and makes it the
recommended auth path; username/password remain as a legacy fallback for
qBit < 5.2.
- QbitClient accepts `api_key`; a new `_auth_kwargs()` helper returns the
Bearer header in key mode or the SID cookie in password mode, used at
every authenticated request site.
- refresh_cookie() and check_qbit_reachability() branch for key mode:
login is skipped (qBit rejects /auth/login under key auth) and
reachability probes /app/version with the Bearer header instead. A
bad key or a <5.2 server both surface a clear tip and degrade instead
of crashing.
- If both api_key and username/password are set, the key wins (mirrors
qBit), logged once at init.
- Redact `Authorization` in sanitize_kwargs so the token never leaks in
DEBUG logs.
- Docs (config example, README) present api_key as recommended, creds as
legacy. Tests cover header-vs-cookie selection, login skip, precedence,
and the 403 degrade path.
# username: "$QBIT_USERNAME" # (legacy -> for qBittorrent < 5.2; ignored if api_key is set)
293
+
# password: "$QBIT_PASSWORD" # (legacy -> for qBittorrent < 5.2; ignored if api_key is set)
293
294
name: "qBittorrent 1" # (optional -> if not provided, assuming "qBittorrent". Must correspond with what is specified in your *arr as download client name)
294
295
- base_url: "http://qbittorrent:8080"
295
296
name: "qBittorrent 2"
@@ -704,8 +705,9 @@ Supported download clients: **qBittorrent** and **SABnzbd**.
704
705
- Type: List of qbit instances
705
706
- Keys per instance
706
707
- base_url: URL under which the qbit can be reached (mandatory)
707
-
- username: Optional - only needed if your qbit requires authentication (which you may not need if you have configured qbit in a way that it disables it for local connections)
708
-
- password: Optional - see above
708
+
- api_key: Recommended - qBittorrent API key (requires qBittorrent 5.2.0 or newer; generate it under Web UI settings). Authenticates without storing credentials, and takes precedence over username/password if both are set.
709
+
- username: Legacy - only for qBittorrent < 5.2, or if your qbit requires authentication (which you may not need if qbit disables it for local connections). Ignored when api_key is set.
710
+
- password: Legacy - see above
709
711
- name: Optional. Needs to correspond with the name that you have set up in your Arr instance. Defaults to "qBittorrent"
Copy file name to clipboardExpand all lines: config/config_example.yaml
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -71,8 +71,9 @@ instances:
71
71
download_clients:
72
72
qbittorrent:
73
73
- base_url: "http://qbittorrent:8080"# You can use decluttarr without qbit (not all features available, see readme).
74
-
# username: xxxx # (optional -> if not provided, assuming not needed)
75
-
# password: xxxx # (optional -> if not provided, assuming not needed)
74
+
# api_key: "qbt_xxxx" # (recommended -> requires qBittorrent 5.2.0+; generate under Web UI settings. Takes precedence over username/password.)
75
+
# username: xxxx # (legacy -> for qBittorrent < 5.2; ignored if api_key is set)
76
+
# password: xxxx # (legacy -> for qBittorrent < 5.2; ignored if api_key is set)
76
77
# name: "qBittorrent" # (optional -> if not provided, assuming "qBittorrent". Must correspond with what is specified in your *arr as download client name)
77
78
# timeout: 30 # (optional -> overrides general timeout for this instance)
"No name provided for qbittorrent client, assuming 'qBitorrent'. If the name used in your *arr is different, please correct either the name in your *arr, or set the name in your config",
79
82
)
80
83
self.name="qBittorrent"
81
84
85
+
ifself.api_keyand (usernameorpassword):
86
+
logger.info(
87
+
f"qBittorrent '{self.name}': both api_key and username/password provided; using api_key (credentials ignored).",
0 commit comments