Skip to content

Validate twitch_oauth.txt session token before use - #5

Merged
second2falcon merged 1 commit into
masterfrom
feat/add-invalid-oauth-message
Sep 23, 2026
Merged

second2falcon merged 1 commit into
masterfrom
feat/add-invalid-oauth-message

Conversation

@second2falcon

Copy link
Copy Markdown
Owner

Problem

An expired or invalid session token in twitch_oauth.txt makes streamlink fail with a generic No playable streams found. That looks the same as the channel being offline, so the real cause is hidden.

Changes

  • TwitchHelper.getSessionToken() reads the token and checks it against id.twitch.tv/oauth2/validate. It doesn't touch the app token (accessToken).
    • 401: logs an error, sends a system notification and returns undefined. Capture continues without auth (no ad-skip or sub-only access) instead of failing.
    • Network or other errors: the token is kept, so a Twitch hiccup doesn't drop auth.
    • The token is added to censoredLogWords here, replacing the per-call-site censoring.
  • Live capture: a TwitchAutomator.captureVideo() override validates the token before streamlink starts, because providerArgs() is sync.
  • VOD-at-end download: uses the same helper. A missing file still throws when auth_enabled is on.
  • Scheduler: checks the token every 6 hours so an expired one is reported before the next stream.
  • Translations: new notify.twitch-oauth-token-expired-or-invalid-check-config-twitch-oauth-txt key, English only.

Not included

  • Detecting the auth failure in streamlink's output inside captureTicker. There's no confirmed error string yet.
  • Showing the token's status in the UI.

Testing

Not typechecked or run locally because dependencies weren't installed. To verify: put a bad token in twitch_oauth.txt, start a capture, and expect a "Twitch token invalid" notification with the recording still going.

🤖 Generated with Claude Code

An expired or invalid session token in twitch_oauth.txt made streamlink
fail with a generic "No playable streams found" error, which looks the
same as the channel being offline.

Add TwitchHelper.getSessionToken(), which reads the token and checks it
against id.twitch.tv/oauth2/validate. On a 401 it logs an error, sends a
system notification and returns undefined, so capture continues without
auth instead of failing silently. Network errors during validation keep
the token so a Twitch hiccup doesn't drop auth.

- Live capture validates the token in a captureVideo() override before
  streamlink starts
- VOD-at-end download uses the same helper
- Scheduler checks the token every 6 hours so an expired one is reported
  before the next stream
- Token censoring moved into the helper
@second2falcon
second2falcon merged commit 12bfc99 into master Sep 23, 2026
1 check passed
@second2falcon
second2falcon deleted the feat/add-invalid-oauth-message branch October 4, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant