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
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!" }
241
251
returnwhen {
242
252
authorization.authorizationCode !=null->try {
243
-
require(clientId !=null&& clientSecret !=null&& redirectUri !=null) { "You need to specify a valid clientId, clientSecret, and redirectUri in the credentials block!" }
244
-
245
-
val response = executeTokenRequest(
246
-
HttpConnection(
247
-
"https://accounts.spotify.com/api/token",
248
-
HttpRequestMethod.POST,
249
-
mapOf(
250
-
"grant_type" to "authorization_code",
251
-
"code" to authorization.authorizationCode,
252
-
"redirect_uri" to redirectUri
253
-
),
254
-
null,
255
-
"application/x-www-form-urlencoded",
256
-
listOf(),
257
-
null
258
-
), clientId, clientSecret
259
-
)
260
-
261
-
SpotifyClientApi(
262
-
clientId,
263
-
clientSecret,
264
-
redirectUri,
265
-
response.body.toObject(Token.serializer(), null),
266
-
options.useCache,
267
-
options.cacheLimit,
268
-
options.automaticRefresh,
269
-
options.retryWhenRateLimited,
270
-
options.enableLogger,
271
-
options.testTokenValidity
272
-
)
273
-
} catch (e:Exception) {
274
-
throwSpotifyAuthenticationException("Invalid credentials provided in the login process", e)
275
-
}
253
+
require(clientId !=null&& clientSecret !=null&& redirectUri !=null) { "You need to specify a valid clientId, clientSecret, and redirectUri in the credentials block!" }
254
+
255
+
val response = executeTokenRequest(
256
+
HttpConnection(
257
+
"https://accounts.spotify.com/api/token",
258
+
HttpRequestMethod.POST,
259
+
mapOf(
260
+
"grant_type" to "authorization_code",
261
+
"code" to authorization.authorizationCode,
262
+
"redirect_uri" to redirectUri
263
+
),
264
+
null,
265
+
"application/x-www-form-urlencoded",
266
+
listOf(),
267
+
null
268
+
), clientId, clientSecret
269
+
)
270
+
271
+
SpotifyClientApi(
272
+
clientId,
273
+
clientSecret,
274
+
redirectUri,
275
+
response.body.toObject(Token.serializer(), null),
276
+
options.useCache,
277
+
options.cacheLimit,
278
+
options.automaticRefresh,
279
+
options.retryWhenRateLimited,
280
+
options.enableLogger,
281
+
options.testTokenValidity
282
+
)
283
+
} catch (e:CancellationException) {
284
+
throw e
285
+
} catch (e:Exception) {
286
+
throwSpotifyAuthenticationException("Invalid credentials provided in the login process", e)
287
+
}
276
288
authorization.token !=null->SpotifyClientApi(
277
289
clientId,
278
290
clientSecret,
@@ -309,49 +321,19 @@ class SpotifyClientApiBuilder(
* Build a public [SpotifyAppApi] using the provided credentials
353
335
*/
354
-
overridefunbuild(): SpotifyApi {
336
+
overridesuspendfunsuspendBuild(): SpotifyAppApi {
355
337
val clientId = credentials.clientId
356
338
val clientSecret = credentials.clientSecret
357
339
require((clientId !=null&& clientSecret !=null) || authorization.token !=null|| authorization.tokenString !=null) { "You didn't specify a client id or client secret in the credentials block!" }
@@ -399,6 +381,8 @@ class SpotifyAppApiBuilder(
399
381
options.enableLogger,
400
382
options.testTokenValidity
401
383
)
384
+
} catch (e:CancellationException) {
385
+
throw e
402
386
} catch (e:Exception) {
403
387
throwSpotifyAuthenticationException("Invalid credentials provided in the login process", e)
0 commit comments