From 8be85f2dd0f9b072849db170d5836e36cfc56969 Mon Sep 17 00:00:00 2001 From: sekuso <124318081+sekuso@users.noreply.github.com> Date: Fri, 2 Oct 2026 21:51:43 -0400 Subject: [PATCH] =?UTF-8?q?when=20invidious=20returns=20403=20on=20authent?= =?UTF-8?q?icated=20request,=20inspect=20error=20be=E2=80=A6=20(#944)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * when invidious returns 403 on authenticated request, inspect error before determining if it's fatal for the user token * simplifying with ibicha's !945 edits - no more followup request to subs endpoint to verify token, just pass if 403 fails for some unk reason --- CHANGELOG.md | 1 + .../Services/Invidious/InvidiousService.bs | 28 +++++++++++-------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e228d9b..c4873f1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Missing shows, seasons, courses and stations (except paid ones) +- Keep Invidious profiles signed in when a 403 does not report a known authentication error ## [0.48.5] - 2026-09-29 diff --git a/playlet-lib/src/components/Services/Invidious/InvidiousService.bs b/playlet-lib/src/components/Services/Invidious/InvidiousService.bs index 5de1238a..6036485d 100644 --- a/playlet-lib/src/components/Services/Invidious/InvidiousService.bs +++ b/playlet-lib/src/components/Services/Invidious/InvidiousService.bs @@ -110,7 +110,7 @@ namespace Invidious request.Headers(m.GetAuthenticationHeaders(auth.token)) request.Cancellation(cancellation) response = request.Await() - m.MarkNeedsReauthOn403(response, auth.profile) + m.MarkNeedsReauthIfCredentialsRejected(response, auth.profile) end function function SearchSuggestions(q as string, cancellation = invalid as object) as object @@ -214,7 +214,7 @@ namespace Invidious response = request.Await() if isAuthenticatedRequest - m.MarkNeedsReauthOn403(response, auth.profile) + m.MarkNeedsReauthIfCredentialsRejected(response, auth.profile) end if return response end function @@ -612,7 +612,7 @@ namespace Invidious function AuthFeedHandler(context as object) as object response = context.response - m.MarkNeedsReauthOn403(response, context.profile) + m.MarkNeedsReauthIfCredentialsRejected(response, context.profile) if not response.IsSuccess() return invalid @@ -647,7 +647,7 @@ namespace Invidious function WatchHistoryHandler(context as object) as object response = context.response - m.MarkNeedsReauthOn403(response, context.profile) + m.MarkNeedsReauthIfCredentialsRejected(response, context.profile) if not response.IsSuccess() return invalid @@ -699,14 +699,20 @@ namespace Invidious return json end function - ' A 403 on an authenticated call is terminal — only a fresh sign-in recovers. - function MarkNeedsReauthOn403(response as object, profile as object) as void + function MarkNeedsReauthIfCredentialsRejected(response as object, profile as object) as void if response.StatusCode() <> 403 return end if - LogWarn(`Invidious instance responded with 403: ${response.Text()}`) - if profile <> invalid and profile.type = "invidious" + body = ValidString(response.Text()) + LogWarn(`Invidious instance responded with 403: ${body}`) + if profile = invalid or profile.type <> "invidious" + return + end if + + ' Invidious answers 403 to any exception on /api/v1/auth/*, including a route failing after + ' authentication succeeded. Only these errors, raised while validating the session, mean it's dead. + if body.InStr("Request must be authenticated") <> -1 or body.InStr("Invalid signature") <> -1 or body.InStr("Erroneous token") <> -1 or body.InStr("Token is expired") <> -1 profile@.MarkNeedsReauth() end if end function @@ -773,7 +779,7 @@ namespace Invidious request.Cancellation(cancellation) response = request.Await() - m.MarkNeedsReauthOn403(response, auth.profile) + m.MarkNeedsReauthIfCredentialsRejected(response, auth.profile) return response end function @@ -787,7 +793,7 @@ namespace Invidious request.Cancellation(cancellation) response = request.Await() - m.MarkNeedsReauthOn403(response, auth.profile) + m.MarkNeedsReauthIfCredentialsRejected(response, auth.profile) return response end function @@ -801,7 +807,7 @@ namespace Invidious request.Cancellation(cancellation) response = request.Await() - m.MarkNeedsReauthOn403(response, auth.profile) + m.MarkNeedsReauthIfCredentialsRejected(response, auth.profile) return response end function end class