From 2fa80b2fd9d48736b226764d87021e4261262929 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Fri, 22 Dec 2023 23:27:27 +0100 Subject: [PATCH] [spotify] Remove logging of "No spotify refresh token found" Logged every time the web UI is used due to call to /api/spotify and during initscan, but it isn't an error, it just means the user isn't logged in. Fixes #1701. --- src/library/spotify_webapi.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/library/spotify_webapi.c b/src/library/spotify_webapi.c index de48b40e..ce0de017 100644 --- a/src/library/spotify_webapi.c +++ b/src/library/spotify_webapi.c @@ -488,15 +488,13 @@ token_refresh(struct spotify_credentials *credentials) if (credentials->token_time_requested && difftime(time(NULL), credentials->token_time_requested) < credentials->token_expires_in) { - DPRINTF(E_DBG, L_SPOTIFY, "Spotify token still valid\n"); - return 0; + return 0; // Spotify token still valid } ret = db_admin_get(&refresh_token, DB_ADMIN_SPOTIFY_REFRESH_TOKEN); if (ret < 0) { - DPRINTF(E_LOG, L_SPOTIFY, "No spotify refresh token found\n"); - goto error; + return -1; // No refresh token (user not logged in) } DPRINTF(E_DBG, L_SPOTIFY, "Spotify refresh-token: '%s'\n", refresh_token); @@ -512,14 +510,18 @@ token_refresh(struct spotify_credentials *credentials) } ret = request_access_tokens(credentials, &kv, &err); + if (ret < 0) + { + DPRINTF(E_LOG, L_SPOTIFY, "Error requesting access token: %s", err); + goto error; + } - if (ret == 0) - request_user_info(credentials); + request_user_info(credentials); free(refresh_token); keyval_clear(&kv); - return ret; + return 0; error: free(refresh_token); @@ -1891,12 +1893,8 @@ spotifywebapi_library_initscan(void) CHECK_ERR(L_SPOTIFY, pthread_mutex_unlock(&spotify_credentials.lock)); if (ret < 0) { - DPRINTF(E_LOG, L_SPOTIFY, "Spotify webapi token refresh failed. " - "In order to use Spotify, authorize the server to access your saved " - "tracks by visiting http://owntone.local:3689\n"); - + // User not logged in or error refreshing token db_spotify_purge(); - return 0; } @@ -1911,7 +1909,6 @@ spotifywebapi_library_initscan(void) "provide valid credentials by visiting http://owntone.local:3689\n"); db_spotify_purge(); - return 0; }