Skip to content

Conversation

@JonnyWong16
Copy link
Collaborator

Description

Plex rotates JWKs used for signing the JWTs. Previously only the first JWK was checked for JWT signature verification resulting in an exception if a different JWK was used. Now all JWKs are checked before raising an exception.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the docstring for new or existing methods
  • I have added tests when applicable

Copilot AI review requested due to automatic review settings January 22, 2026 07:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens Plex JWT handling in MyPlexJWTLogin to support key rotation and avoid failures when Plex publishes multiple signing keys, and adds coverage for the JWT login flow.

Changes:

  • Refactors Plex JWT decoding to iterate over all public JWKs returned by Plex, trying each key until one verifies the JWT, and optionally allows decoding without signature verification.
  • Adjusts _getPlexPublicJWK and the internal _query helper to better handle JSON responses (including empty bodies) and updated the decodedJWT property to expose a non-verifying decode view.
  • Adds an integration-style test for MyPlexJWTLogin covering keypair generation, device registration, JWT refresh, verification, and re-instantiation from an existing token.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
plexapi/myplex.py Updates MyPlexJWTLogin’s JWT decode/verify logic to loop over all Plex JWKs, tweaks error handling, and makes _query more robust to empty JSON responses.
tests/test_myplex.py Imports MyPlexAccount/MyPlexJWTLogin and adds test_myplex_jwt_login to exercise the JWT login, refresh, and verification workflow end-to-end.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

JonnyWong16 and others added 2 commits January 22, 2026 00:46
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant