{"record":{"id":"3d97a2606cbcef56","repo":"Sonarr/Sonarr","slug":"authentication-failed-check-your-api-key","errorCode":null,"errorMessage":"Authentication failed, check your API Key","messagePattern":"Authentication failed, check your API Key","errorType":"exception","errorClass":"NzbVortexAuthenticationException","httpStatus":null,"severity":"error","filePath":"src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortexProxy.cs","lineNumber":207,"sourceCode":"\n                var nonce = Json.Deserialize<NzbVortexAuthNonceResponse>(nonceResponse.Content).AuthNonce;\n\n                var cnonce = Guid.NewGuid().ToString();\n\n                var hashString = string.Format(\"{0}:{1}:{2}\", nonce, cnonce, settings.ApiKey);\n                var hash = Convert.ToBase64String(hashString.SHA256Hash().HexToByteArray());\n\n                var authRequest = BuildRequest(settings).Resource(\"auth/login\")\n                                                        .AddQueryParam(\"nonce\", nonce)\n                                                        .AddQueryParam(\"cnonce\", cnonce)\n                                                        .AddQueryParam(\"hash\", hash)\n                                                        .Build();\n                var authResponse = _httpClient.Execute(authRequest);\n                var authResult = Json.Deserialize<NzbVortexAuthResponse>(authResponse.Content);\n\n                if (authResult.LoginResult == NzbVortexLoginResultType.Failed)\n                {\n                    throw new NzbVortexAuthenticationException(\"Authentication failed, check your API Key\");\n                }\n\n                sessionId = authResult.SessionId;\n\n                _authSessionIdCache.Set(authKey, sessionId);\n            }\n\n            requestBuilder.AddQueryParam(\"sessionid\", sessionId);\n        }\n    }\n}\n","sourceCodeStart":189,"sourceCodeEnd":219,"githubUrl":"https://github.com/Sonarr/Sonarr/blob/da2284d7eaab22ed9b2ca698af690148d691e967/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortexProxy.cs#L189-L219","documentation":"Thrown as NzbVortexAuthenticationException when NZBVortex's auth/login endpoint returns NzbVortexLoginResultType.Failed. NZBVortex uses a nonce/cnonce challenge-response scheme: Sonarr requests a server nonce, generates a client nonce, computes SHA256(nonce:cnonce:apiKey), and sends the hash. If NZBVortex cannot validate the hash against its stored API key, it returns a Failed login result and Sonarr throws this exception. The session ID is never cached, so every subsequent request that triggers re-authentication will fail again.","triggerScenarios":"The API Key in Sonarr's NZBVortex settings does not match the API key configured in the NZBVortex application. The authentication flow (lines 187-208) fetches a nonce, computes SHA256(nonce:cnonce:apiKey), posts to auth/login, and deserializes the response — if LoginResult equals Failed, the exception fires.","commonSituations":"The API key was regenerated in NZBVortex but not updated in Sonarr; the API key was copy-pasted with trailing whitespace or a typo; NZBVortex was reinstalled/reset and got a new key; the user confused the API key with the web UI password.","solutions":["Open NZBVortex's settings/preferences and copy the current API key, then paste it into Sonarr > Settings > Download Clients > NZBVortex > API Key.","Verify the API key has no leading/trailing whitespace after pasting (Sonarr does not trim it automatically).","If unsure whether the key is correct, regenerate a new API key in NZBVortex and update both sides.","Test the connection using the 'Test' button in Sonarr's download client settings after updating."],"exampleFix":"// before: stale API key\nvar settings = new NzbVortexSettings { ApiKey = \"old-or-wrong-key\" };\n\n// after: key copied verbatim from NZBVortex preferences\nvar settings = new NzbVortexSettings { ApiKey = \"abc123-exact-key-from-nzbvortex\" };","handlingStrategy":"validation","validationCode":"// Validate API key format before attempting authentication\npublic bool IsApiKeyValidFormat(string apiKey)\n{\n    if (string.IsNullOrWhiteSpace(apiKey)) return false;\n    if (apiKey.Length < 8) return false;\n    if (apiKey.Any(char.IsWhiteSpace)) return false;\n    return true;\n}","typeGuard":"public bool IsNzbVortexAuthLikelyValid(NzbVortexSettings settings)\n{\n    return !string.IsNullOrWhiteSpace(settings.ApiKey)\n        && !settings.ApiKey.Any(char.IsWhiteSpace)\n        && settings.ApiKey.Length >= 8;\n}","tryCatchPattern":"try\n{\n    _proxy.AuthenticateClient(requestBuilder, settings);\n}\ncatch (NzbVortexAuthenticationException ex)\n{\n    _logger.Error(ex, \"NZBVortex API key is incorrect — update settings\");\n    // Do NOT retry — auth failure is persistent until config changes\n    throw;\n}","preventionTips":["Copy the API key directly from NZBVortex's preferences screen using copy-paste, not manual typing.","Trim whitespace from pasted API keys (some UIs add trailing spaces).","After changing the API key in NZBVortex, update Sonarr immediately to prevent repeated auth failures.","Use the 'Test' button after configuring the API key to verify before closing settings."],"tags":["nzbvortex","authentication","api-key","download-client","csharp"],"backgroundTag":null,"analyzedSha":"da2284d7eaab22ed9b2ca698af690148d691e967","analyzedAt":"2026-08-13T15:53:02.562Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}