vosmiic / jellyfin-ani-sync

Synchronize anime watch status between Jellyfin and anime tracking sites.
GNU General Public License v3.0
250 stars 18 forks source link

Unable to access auth callback URL, given a 400 error "One or more validation errors occurred." #113

Closed slmnemo closed 6 months ago

slmnemo commented 6 months ago

Describe the bug Using the official docker image for jellyfin (jellyfin/jellyfin) and accessing the generated auto callback URL results in a 400 error One or more validation errors occurred. . Expected behavior is seeing the message for a correct callback URL.

Logs Log is very large, but repeats the line [2024-03-18 05:35:00.197 +00:00] [INF] [11] Jellyfin.Api.Auth.CustomAuthenticationHandler: "CustomAuthentication" was not authenticated. Failure message: "Invalid token." [2024-03-18 05:35:00.198 +00:00] [INF] [11] Jellyfin.Api.Auth.CustomAuthenticationHandler: "CustomAuthentication" was not authenticated. Failure message: "Invalid token." [2024-03-18 05:35:00.201 +00:00] [INF] [11] Jellyfin.Api.Auth.CustomAuthenticationHandler: AuthenticationScheme: "CustomAuthentication" was challenged.

To Reproduce Run jellyfin using docker-compose on Ubuntu 22.04 with NVIDIA support. Install Ani-Sync. Try to access auth callback URL.

Expected behavior Accessing auth callback URL results in the "This is the correct page" response.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information): Jellyfin 10.8.13 Plugin Version 3.0 Firefox

slmnemo commented 6 months ago

More log info. It also fails to create an api link for anilist, causing this error when I attempt it.

[2024-03-18 08:05:17.248 +00:00] [ERR] [56] Jellyfin.Server.Middleware.ExceptionMiddleware: Error processing request. URL "GET" "/AniSync/user". System.ArgumentNullException: Value cannot be null. (Parameter 'source') at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument) at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable1 source, Func2 predicate, Boolean& found) at jellyfin_ani_sync.Api.AuthApiCall.AuthenticatedApiCall(ApiName provider, CallType callType, String url, FormUrlEncodedContent formUrlEncodedContent, StringContent stringContent, Dictionary2 requestHeaders) at jellyfin_ani_sync.Helpers.GraphQlHelper.AuthenticatedRequest(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, IServerApplicationHost serverApplicationHost, IHttpContextAccessor httpContextAccessor, UserConfig userConfig, String query, ApiName provider, Dictionary2 variables) at jellyfin_ani_sync.Api.Anilist.AniListApiCalls.GetCurrentUser() at jellyfin_ani_sync.Api.AniSyncController.GetUser(ApiName apiName, String userId) at lambda_method1628(Closure , Object ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.gAwaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Routing.EndpointMiddleware.gAwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Jellyfin.Server.Middleware.ServerStartupMessageMiddleware.Invoke(HttpContext httpContext, IServerApplicationHost serverApplicationHost, ILocalizationManager localizationManager) at Jellyfin.Server.Middleware.WebSocketHandlerMiddleware.Invoke(HttpContext httpContext, IWebSocketManager webSocketManager) at Jellyfin.Server.Middleware.IpBasedAccessValidationMiddleware.Invoke(HttpContext httpContext, INetworkManager networkManager) at Jellyfin.Server.Middleware.LanFilteringMiddleware.Invoke(HttpContext httpContext, INetworkManager networkManager, IServerConfigurationManager serverConfigurationManager) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Jellyfin.Server.Middleware.QueryStringDecodingMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.ReDoc.ReDocMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Jellyfin.Server.Middleware.RobotsRedirectionMiddleware.Invoke(HttpContext httpContext) at Jellyfin.Server.Middleware.LegacyEmbyRouteRewriteMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.InvokeCore(HttpContext context) at Jellyfin.Server.Middleware.ResponseTimeMiddleware.Invoke(HttpContext context, IServerConfigurationManager serverConfigurationManager) at Jellyfin.Server.Middleware.ExceptionMiddleware.Invoke(HttpContext context)

vosmiic commented 6 months ago

Normally when you get the One or more validation errors occurred. error it includes at least one error description, could you post the entire returned JSON (removing any private information it contains if applicable)?

slmnemo commented 6 months ago

here's the whole JSON {"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1","title":"One or more validation errors occurred.","status":400,"traceId":"00-202d16469baae8cfaea3b4ecbaaf2dfb-4d34275b1beb51e7-00","errors":{"code":["The code field is required."]}}

vosmiic commented 6 months ago

So that means that the code field isn't being supplied. Your URL should contain the code query parameter. What provider are you attempting to authenticate with?

I would advise following the wiki instructions if you haven't already done so: https://github.com/vosmiic/jellyfin-ani-sync/wiki/Providers-Setup

slmnemo commented 6 months ago

I'm incredibly silly and have been visiting the authCallback page instead of the apiUrlTest page. I am so sorry for the issue.

vosmiic commented 6 months ago

No worries, if you hit into any trouble using the plugin feel free to create an issue/discussion 👍