You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement possibility to suspend function for requests
* Reformat code
* Simplified some code (e. g. HttpConnection)
* Allow the user to select the scope of the network request by setting
all functions in between to be suspending
@@ -242,39 +243,41 @@ class SpotifyClientApiBuilder(
242
243
243
244
require((clientId !=null&& clientSecret !=null&& redirectUri !=null) || authorization.token !=null|| authorization.tokenString !=null) { "You need to specify a valid clientId, clientSecret, and redirectUri in the credentials block!" }
244
245
returnwhen {
245
-
authorization.authorizationCode !=null->try {
246
-
require(clientId !=null&& clientSecret !=null&& redirectUri !=null) { "You need to specify a valid clientId, clientSecret, and redirectUri in the credentials block!" }
247
-
248
-
val response = executeTokenRequest(
249
-
HttpConnection(
250
-
"https://accounts.spotify.com/api/token",
251
-
HttpRequestMethod.POST,
252
-
mapOf(
253
-
"grant_type" to "authorization_code",
254
-
"code" to authorization.authorizationCode,
255
-
"redirect_uri" to redirectUri
256
-
),
257
-
null,
258
-
"application/x-www-form-urlencoded",
259
-
listOf(),
260
-
null
261
-
), clientId, clientSecret
262
-
)
263
-
264
-
SpotifyClientApi(
265
-
clientId,
266
-
clientSecret,
267
-
redirectUri,
268
-
response.body.toObject(Token.serializer(), null),
269
-
options.useCache,
270
-
options.cacheLimit,
271
-
options.automaticRefresh,
272
-
options.retryWhenRateLimited,
273
-
options.enableLogger,
274
-
options.testTokenValidity
275
-
)
276
-
} catch (e:Exception) {
277
-
throwSpotifyAuthenticationException("Invalid credentials provided in the login process", e)
require(clientId !=null&& clientSecret !=null&& redirectUri !=null) { "You need to specify a valid clientId, clientSecret, and redirectUri in the credentials block!" }
249
+
250
+
val response = executeTokenRequest(
251
+
HttpConnection(
252
+
"https://accounts.spotify.com/api/token",
253
+
HttpRequestMethod.POST,
254
+
mapOf(
255
+
"grant_type" to "authorization_code",
256
+
"code" to authorization.authorizationCode,
257
+
"redirect_uri" to redirectUri
258
+
),
259
+
null,
260
+
"application/x-www-form-urlencoded",
261
+
listOf(),
262
+
null
263
+
), clientId, clientSecret
264
+
)
265
+
266
+
SpotifyClientApi(
267
+
clientId,
268
+
clientSecret,
269
+
redirectUri,
270
+
response.body.toObject(Token.serializer(), null),
271
+
options.useCache,
272
+
options.cacheLimit,
273
+
options.automaticRefresh,
274
+
options.retryWhenRateLimited,
275
+
options.enableLogger,
276
+
options.testTokenValidity
277
+
)
278
+
} catch (e:Exception) {
279
+
throwSpotifyAuthenticationException("Invalid credentials provided in the login process", e)
0 commit comments