Skip to content

Revoke the stored token directly when de-authorizing - #343

Open
zotabee wants to merge 1 commit into
jellyfin:masterfrom
zotabee:fix-revoke-token
Open

zotabee wants to merge 1 commit into
jellyfin:masterfrom
zotabee:fix-revoke-token

Conversation

@zotabee

@zotabee zotabee commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

De-authorizing a user sent the token revoke through PostToTrakt<T>, which doesn't fit this request in two ways:

  • trakt.tv answers the revoke with 200 and an empty body. Reading that as JSON threw a JsonException, so every de-authorization logged "Exception handled in PostToTrakt", although the token was revoked.
  • If the stored token had passed the plugin's refresh point (3/4 of its lifetime) and no request had refreshed it yet, PostToTrakt<T> refreshed it first, while the revoke still named the old token. The new token stayed valid on trakt.tv, and the plugin deleted its copy.

The revoke now goes through the plain PostToTrakt that the other OAuth requests use: it sends the stored token, doesn't refresh it and doesn't read the body. A failed revoke is logged as a warning with its status code; the user is still removed either way.

Tested with the real DeauthorizeDevice against a fake trakt.tv:

De-authorizing master This PR
trakt.tv answers 200 with an empty body error: JsonException nothing logged
token past the refresh point refreshed, then the old token revoked; the new one stays valid the stored token revoked
trakt.tv answers 500 error: HttpRequestException warning: Couldn't revoke the access token on trakt.tv: 500

Also checked against trakt.tv with the plugin's client id: the revoke returns 200 with an empty body, a token revoked without an Authorization header (as this PR sends it) is rejected right after, and revoking the previous token after a refresh leaves the new one valid (still accepted 6 minutes later). On my Jellyfin 12.1 server, de-authorizing a user logged the JsonException, and its token was rejected afterwards.

Builds with no warnings. Merges cleanly with #328, which leaves the revoke out of its debug logging; with this change the revoke no longer goes through that code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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