From: Marcel van der Veldt Date: Fri, 19 Dec 2025 02:36:33 +0000 (+0100) Subject: Fix Plex login flow X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=4ed4d6e1c4f8d80a866cd605a0d05cf00dc0165a;p=music-assistant-server.git Fix Plex login flow --- diff --git a/music_assistant/providers/plex/__init__.py b/music_assistant/providers/plex/__init__.py index 4a423843..c735728c 100644 --- a/music_assistant/providers/plex/__init__.py +++ b/music_assistant/providers/plex/__init__.py @@ -170,7 +170,13 @@ async def get_config_entries( # noqa: PLR0915 plex_auth = MyPlexPinLogin(headers={"X-Plex-Product": "Music Assistant"}, oauth=True) auth_url = plex_auth.oauthUrl(auth_helper.callback_url) await auth_helper.authenticate(auth_url) - if not plex_auth.checkLogin(): + # Poll checkLogin() as the token may not be immediately available after OAuth callback + # The Plex OAuth flow needs time to propagate the token + for _ in range(30): # Poll for up to 30 seconds + if plex_auth.checkLogin(): + break + await asyncio.sleep(1) + if not plex_auth.token: msg = "Authentication to MyPlex failed" raise LoginFailed(msg) # set the retrieved token on the values object to pass along