Open Hona opened 3 years ago
If anyone runs into this issue with no workaround, I added this code which should work:
private async Task EnsureLoggedIn()
{
try
{
await _qbittorrent.GetApiVersionAsync();
}
catch (QBittorrentClientRequestException e)
{
if (e.StatusCode == HttpStatusCode.Forbidden)
{
_logger.LogWarning("Qbittorrent logged out, logging in again");
await _qbittorrent.LoginAsync(_username, _password);
}
}
}
After the QbittorrentClient instance runs for long enough, it returns 403 Forbidden to requests, so it would be nice to have a way to check if the client is logged in, and if not refresh authentication/relogin