File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
src/main/kotlin/com/adamratzman/spotify/main Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -249,8 +249,10 @@ class SpotifyApiBuilder {
249249}
250250
251251abstract class SpotifyAPI internal constructor(
252- val clientId : String , val clientSecret : String ,
253- var token : Token , var useCache : Boolean
252+ val clientId : String ,
253+ val clientSecret : String ,
254+ var token : Token ,
255+ var useCache : Boolean
254256) {
255257 internal var expireTime = System .currentTimeMillis() + token.expires_in * 1000
256258 internal val executor = Executors .newScheduledThreadPool(2 )
@@ -386,10 +388,13 @@ class SpotifyClientAPI internal constructor(
386388 contentType = " application/x-www-form-urlencoded"
387389 ).execute(HttpHeader (" Authorization" , " Basic ${" $clientId :$clientSecret " .byteEncode()} " )).body
388390 .toObjectNullable<Token >(null )
389- if (tempToken == null ) {
391+ if (tempToken?.access_token == null ) {
390392 logger.logWarning(" Spotify token refresh failed" )
391393 } else {
392- this .token = tempToken
394+ this .token = tempToken.copy(
395+ refresh_token = tempToken.refresh_token ? : this .token.refresh_token,
396+ scope = tempToken.scope ? : this .token.scope
397+ )
393398 logger.logInfo(" Successfully refreshed the Spotify token" )
394399 }
395400 }
You can’t perform that action at this time.
0 commit comments