Skip to content

Commit

Permalink
redacted: fixed login loop for api key (#12416) resolves #12392
Browse files Browse the repository at this point in the history
Co-authored-by: garfield69 <garfield69@outlook.com>
  • Loading branch information
seeyabye and garfield69 committed Oct 13, 2021
1 parent 1ed49b5 commit ab9f7bb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Jackett.Common/Indexers/Abstract/GazelleTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,20 @@ protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuer

var response = await RequestWithCookiesAndRetryAsync(searchUrl, headers: headers);
// we get a redirect in html pages and an error message in json response (api)
if (response.IsRedirect || (response.ContentString != null && response.ContentString.Contains("\"bad credentials\"")))
if (response.IsRedirect && !useApiKey)
{
// re-login
// re-login only if API key is not in use.
await ApplyConfiguration(null);
response = await RequestWithCookiesAndRetryAsync(searchUrl);
}
else if (response.ContentString != null && response.ContentString.Contains("failure") && useApiKey)
{
// reason for failure should be explained.
var jsonError = JObject.Parse(response.ContentString);
var errorReason = (string)jsonError["error"];
throw new Exception(errorReason);
}


try
{
Expand Down

0 comments on commit ab9f7bb

Please sign in to comment.