From 383990d002b2728f9e2c971829fd49a0ed2a54dc Mon Sep 17 00:00:00 2001 From: Alix von Schirp Date: Sat, 28 Jan 2023 07:21:17 +0100 Subject: [PATCH] Reimplemented refreshing access token May fix #17 --- .../tools/lastfmtospotifyplaylist/LastFMToSpotify.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/b00tload/tools/lastfmtospotifyplaylist/LastFMToSpotify.java b/src/main/java/de/b00tload/tools/lastfmtospotifyplaylist/LastFMToSpotify.java index c96ca36..8a7de20 100644 --- a/src/main/java/de/b00tload/tools/lastfmtospotifyplaylist/LastFMToSpotify.java +++ b/src/main/java/de/b00tload/tools/lastfmtospotifyplaylist/LastFMToSpotify.java @@ -84,7 +84,8 @@ public class LastFMToSpotify { logLn("Cached credentials have been found.", 2); logLn("Fetching old credentials, refreshing them and saving to cache", 2); AuthorizationCodeCredentials oldcred = TokenHelper.fetchTokens(); - AuthorizationCodeCredentials newcred = api.authorizationCodeRefresh(api.getClientId(), api.getClientSecret(), oldcred.getRefreshToken()).setHeader("User-Agent", configuration.get("requests.useragent")).build().execute(); + api.setRefreshToken(oldcred.getRefreshToken()); + AuthorizationCodeCredentials newcred = api.authorizationCodeRefresh().build().execute(); TokenHelper.saveTokens(newcred); configuration.put("spotify.access", newcred.getAccessToken()); } else {