From: Marcel van der Veldt Date: Thu, 22 Aug 2024 11:18:13 +0000 (+0200) Subject: Fix Tidal login auth flow not showing (#1595) X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=d42e9840932fad794c869789ee4d791735745ad3;p=music-assistant-server.git Fix Tidal login auth flow not showing (#1595) * Fix for tidal auth flow * textual change for spotify as well --- diff --git a/music_assistant/server/providers/spotify/__init__.py b/music_assistant/server/providers/spotify/__init__.py index 7535ea5d..a16ec9f6 100644 --- a/music_assistant/server/providers/spotify/__init__.py +++ b/music_assistant/server/providers/spotify/__init__.py @@ -177,6 +177,7 @@ async def get_config_entries( "You need to authenticate to Spotify. Click the authenticate button below " "to start the authentication process which will open in a new (popup) window, " "so make sure to disable any popup blockers.\n\n" + "Also make sure to perform this action from your local network" ) elif action == CONF_ACTION_AUTH: label_text = "Authenticated to Spotify. Press save to complete setup." diff --git a/music_assistant/server/providers/tidal/__init__.py b/music_assistant/server/providers/tidal/__init__.py index eca690eb..df1d47da 100644 --- a/music_assistant/server/providers/tidal/__init__.py +++ b/music_assistant/server/providers/tidal/__init__.py @@ -176,6 +176,11 @@ async def get_config_entries( quality: str = values.get(CONF_QUALITY) if values else None base64_session = await tidal_auth_url(auth_helper, cast(str, quality)) values[CONF_TEMP_SESSION] = base64_session + # Tidal is (ab)using the AuthenticationHelper just to send the user to an URL + # there is no actual oauth callback happening, instead the user is redirected + # to a non-existent page and needs to copy the URL from the browser and paste it + # we simply wait here to allow the user to start the auth + await asyncio.sleep(15) if action == CONF_ACTION_COMPLETE_PKCE_LOGIN: quality: str = values.get(CONF_QUALITY) if values else None @@ -197,6 +202,11 @@ async def get_config_entries( if values.get(CONF_AUTH_TOKEN): auth_entries = ( + ConfigEntry( + key="label_ok", + type=ConfigEntryType.LABEL, + label="You are authenticated with Tidal", + ), ConfigEntry( key=CONF_ACTION_CLEAR_AUTH, type=ConfigEntryType.ACTION, @@ -230,9 +240,11 @@ async def get_config_entries( ConfigEntry( key=LABEL_START_PKCE_LOGIN, type=ConfigEntryType.LABEL, - label="The button below will redirect you to Tidal.com to authenticate." + label="The button below will redirect you to Tidal.com to authenticate.\n\n" " After authenticating, you will be redirected to a page that prominently displays" - " 'Oops' at the top.", + " 'Oops' at the top. That is normal, you need to copy that URL from the " + "address bar and come back here", + hidden=action == CONF_ACTION_START_PKCE_LOGIN, ), ConfigEntry( key=CONF_ACTION_START_PKCE_LOGIN, @@ -245,6 +257,7 @@ async def get_config_entries( depends_on=CONF_QUALITY, action_label="Starts the auth process via PKCE on Tidal.com", value=values.get(CONF_TEMP_SESSION) if values else None, + hidden=action == CONF_ACTION_START_PKCE_LOGIN, ), ConfigEntry( key=CONF_TEMP_SESSION, @@ -259,6 +272,7 @@ async def get_config_entries( type=ConfigEntryType.LABEL, label="Copy the URL from the 'Oops' page that you were previously redirected to" " and paste it in the field below", + hidden=action != CONF_ACTION_START_PKCE_LOGIN, ), ConfigEntry( key=CONF_OOPS_URL, @@ -269,12 +283,14 @@ async def get_config_entries( " 'Oops' at the top.", depends_on=CONF_ACTION_START_PKCE_LOGIN, value=values.get(CONF_OOPS_URL) if values else None, + hidden=action != CONF_ACTION_START_PKCE_LOGIN, ), ConfigEntry( key=LABEL_COMPLETE_PKCE_LOGIN, type=ConfigEntryType.LABEL, label="After pasting the URL in the field above, click the button below to complete" " the process.", + hidden=action != CONF_ACTION_START_PKCE_LOGIN, ), ConfigEntry( key=CONF_ACTION_COMPLETE_PKCE_LOGIN, @@ -286,6 +302,7 @@ async def get_config_entries( depends_on=CONF_OOPS_URL, action_label="Complete the auth process via PKCE on Tidal.com", value=None, + hidden=action != CONF_ACTION_START_PKCE_LOGIN, ), )