Skip to content

feat: add API token authentication support for qBittorrent v5.2.0+#212

Open
hongcankun wants to merge 1 commit into
jerrymakesjelly:masterfrom
hongcankun:feat/qbittorrent-api-token-auth
Open

feat: add API token authentication support for qBittorrent v5.2.0+#212
hongcankun wants to merge 1 commit into
jerrymakesjelly:masterfrom
hongcankun:feat/qbittorrent-api-token-auth

Conversation

@hongcankun
Copy link
Copy Markdown

Summary

Add support for API token authentication in qBittorrent v5.2.0+ (WebAPI v2.14.1+), allowing users to authenticate using an API token instead of username/password.

Motivation

qBittorrent v5.2.0 introduced API token authentication as a more secure alternative to traditional username/password authentication. This change allows autoremove-torrents to use API tokens for authentication with compatible qBittorrent versions.

Changes

Modified Files

  • autoremovetorrents/client/deluge.py: Updated login method to accept optional api_token parameter
  • autoremovetorrents/client/qbittorrent.py:
    • Updated login method in both API v1 and API v2 handlers to accept optional api_token parameter
    • Added Bearer token authentication for API v2 (qBittorrent v5.2.0+)
    • Updated login success check to handle API token authentication (which uses server_state() to verify token validity)
  • autoremovetorrents/client/transmission.py: Updated login method to accept optional api_token parameter
  • autoremovetorrents/client/utorrent.py: Updated login method to accept optional api_token parameter
  • autoremovetorrents/task.py:
    • Added support for api_token in configuration (including environment variable replacement)
    • Updated debug logging to include API token
    • Pass api_token to client login method
  • docs/config.rst: Updated documentation to include api_token configuration option

Usage Example

my_task:
  client: qbittorrent
  host: http://127.0.0.1:8080
  api_token: your_api_token_here
  strategies:
    my_strategy:
      ratio: 1

Features

  • Supports API token authentication for qBittorrent v5.2.0+ (WebAPI v2.14.1+)
  • Allows omitting username/password when using API token
  • Backward compatible with existing username/password authentication
  • Environment variable replacement for api_token (e.g., api_token: $(QBITTORRENT_API_TOKEN))

Testing

Tested with qBittorrent v5.2.0+ using API token authentication and verified backward compatibility with username/password authentication.

Checklist

  • Code follows project style
  • Backward compatible (no breaking changes to existing functionality)
  • Documentation updated
  • Tested with real qBittorrent instance

@hongcankun hongcankun marked this pull request as ready for review May 21, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant