@@ -20,6 +20,7 @@ import com.adamratzman.spotify.models.Token
2020import com.adamratzman.spotify.spotifyClientPkceApi
2121import com.adamratzman.spotify.spotifyImplicitGrantApi
2222import com.adamratzman.spotify.utils.logToConsole
23+ import kotlinx.coroutines.runBlocking
2324
2425/* *
2526 * Provided credential store for holding current Spotify token credentials, allowing you to easily store and retrieve
@@ -149,19 +150,21 @@ public class SpotifyDefaultCredentialStore(
149150 *
150151 * @param block Applied configuration to the [SpotifyImplicitGrantApi]
151152 */
152- public suspend fun getSpotifyClientPkceApi (block : ((SpotifyApiOptions ).() -> Unit )? = null): SpotifyClientApi ? {
153+ public fun getSpotifyClientPkceApi (block : ((SpotifyApiOptions ).() -> Unit )? = null): SpotifyClientApi ? {
153154 val token = spotifyToken ? : return null
154- return spotifyClientPkceApi(
155- clientId,
156- redirectUri,
157- SpotifyUserAuthorization (token = token),
158- block ? : {}
159- ).build().apply {
160- val previousAfterTokenRefresh = spotifyApiOptions.afterTokenRefresh
161- spotifyApiOptions.afterTokenRefresh = {
162- spotifyToken = this .token
163- logToConsole(" Refreshed Spotify PKCE token in credential store... $token " )
164- previousAfterTokenRefresh?.invoke(this )
155+ return runBlocking {
156+ spotifyClientPkceApi(
157+ clientId,
158+ redirectUri,
159+ SpotifyUserAuthorization (token = token),
160+ block ? : {}
161+ ).build().apply {
162+ val previousAfterTokenRefresh = spotifyApiOptions.afterTokenRefresh
163+ spotifyApiOptions.afterTokenRefresh = {
164+ spotifyToken = this .token
165+ logToConsole(" Refreshed Spotify PKCE token in credential store... $token " )
166+ previousAfterTokenRefresh?.invoke(this )
167+ }
165168 }
166169 }
167170 }
0 commit comments