Reimplemented refreshing access token

May fix #17
This commit is contained in:
2023-01-28 07:21:17 +01:00
parent b696839ee9
commit 383990d002

View File

@@ -84,7 +84,8 @@ public class LastFMToSpotify {
logLn("Cached credentials have been found.", 2); logLn("Cached credentials have been found.", 2);
logLn("Fetching old credentials, refreshing them and saving to cache", 2); logLn("Fetching old credentials, refreshing them and saving to cache", 2);
AuthorizationCodeCredentials oldcred = TokenHelper.fetchTokens(); 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); TokenHelper.saveTokens(newcred);
configuration.put("spotify.access", newcred.getAccessToken()); configuration.put("spotify.access", newcred.getAccessToken());
} else { } else {