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 @@ -245,8 +245,10 @@ class SpotifyApiBuilder {
245245}
246246
247247abstract class SpotifyAPI internal constructor(
248- val clientId : String , val clientSecret : String ,
249- var token : Token , var useCache : Boolean
248+ val clientId : String ,
249+ val clientSecret : String ,
250+ var token : Token ,
251+ var useCache : Boolean
250252) {
251253 internal var expireTime = System .currentTimeMillis() + token.expires_in * 1000
252254 internal val executor = Executors .newScheduledThreadPool(2 )
@@ -378,10 +380,13 @@ class SpotifyClientAPI internal constructor(
378380 ).execute(HttpHeader (" Authorization" , " Basic ${" $clientId :$clientSecret " .byteEncode()} " )).body,
379381 Token ::class .java
380382 )
381- if (tempToken == null ) {
383+ if (tempToken?.access_token == null ) {
382384 logger.logWarning(" Spotify token refresh failed" )
383385 } else {
384- this .token = tempToken
386+ this .token = tempToken.copy(
387+ refresh_token = tempToken.refresh_token ? : this .token.refresh_token,
388+ scope = tempToken.scope ? : this .token.scope
389+ )
385390 logger.logInfo(" Successfully refreshed the Spotify token" )
386391 }
387392 }
You can’t perform that action at this time.
0 commit comments