Skip to content

Commit

Permalink
[spotify] Remove logging of "No spotify refresh token found"
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ejurgensen committed Dec 22, 2023
1 parent 045edf7 commit 2fa80b2
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/library/spotify_webapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}

Expand All @@ -1911,7 +1909,6 @@ spotifywebapi_library_initscan(void)
"provide valid credentials by visiting http://owntone.local:3689\n");

db_spotify_purge();

return 0;
}

Expand Down

0 comments on commit 2fa80b2

Please sign in to comment.