@@ -20,6 +20,7 @@ import com.adamratzman.spotify.models.Token
20
20
import com.adamratzman.spotify.spotifyClientPkceApi
21
21
import com.adamratzman.spotify.spotifyImplicitGrantApi
22
22
import com.adamratzman.spotify.utils.logToConsole
23
+ import kotlinx.coroutines.runBlocking
23
24
24
25
/* *
25
26
* Provided credential store for holding current Spotify token credentials, allowing you to easily store and retrieve
@@ -149,19 +150,21 @@ public class SpotifyDefaultCredentialStore(
149
150
*
150
151
* @param block Applied configuration to the [SpotifyImplicitGrantApi]
151
152
*/
152
- public suspend fun getSpotifyClientPkceApi (block : ((SpotifyApiOptions ).() -> Unit )? = null): SpotifyClientApi ? {
153
+ public fun getSpotifyClientPkceApi (block : ((SpotifyApiOptions ).() -> Unit )? = null): SpotifyClientApi ? {
153
154
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
+ }
165
168
}
166
169
}
167
170
}
0 commit comments