@@ -114,7 +114,29 @@ public fun getSpotifyPkceCodeChallenge(codeVerifier: String): String {
114
114
public fun spotifyImplicitGrantApi (
115
115
clientId : String? ,
116
116
token : Token ,
117
- block : SpotifyApiOptions .() -> Unit = { }
117
+ ): SpotifyImplicitGrantApi = SpotifyImplicitGrantApi (
118
+ clientId,
119
+ token,
120
+ SpotifyApiOptions ()
121
+ )
122
+
123
+
124
+ /* *
125
+ * Instantiate a new [SpotifyImplicitGrantApi] using a Spotify [clientId], and [token] retrieved from the implicit
126
+ * grant flow.
127
+ *
128
+ * Use case: I have a token obtained after implicit grant authorization.
129
+ *
130
+ * @param clientId Spotify [client id](https://developer.spotify.com/documentation/general/guides/app-settings/)
131
+ * @param token Token created from the hash response in the implicit grant callback
132
+ * @param block Block to set API options
133
+ *
134
+ * @return [SpotifyImplicitGrantApi] that can immediately begin making calls
135
+ */
136
+ public fun spotifyImplicitGrantApi (
137
+ clientId : String? ,
138
+ token : Token ,
139
+ block : SpotifyApiOptions .() -> Unit
118
140
): SpotifyImplicitGrantApi = SpotifyImplicitGrantApi (
119
141
clientId,
120
142
token,
@@ -135,6 +157,28 @@ public fun spotifyImplicitGrantApi(
135
157
|| ||
136
158
*/
137
159
160
+ /* *
161
+ * Instantiate a new [SpotifyAppApiBuilder] using a Spotify [clientId] and [clientSecret].
162
+ *
163
+ * Use case: I am using the client credentials flow.
164
+ * I only need access to public Spotify API endpoints, might have an existing token,
165
+ * and might want to deal with advanced configuration.
166
+ *
167
+ * @param clientId Spotify [client id](https://developer.spotify.com/documentation/general/guides/app-settings/)
168
+ * @param clientSecret Spotify [client secret](https://developer.spotify.com/documentation/general/guides/app-settings/)
169
+ *
170
+ * @return Configurable [SpotifyAppApiBuilder] that, when built, creates a new [SpotifyAppApi]
171
+ */
172
+ public fun spotifyAppApi (
173
+ clientId : String ,
174
+ clientSecret : String
175
+ ): SpotifyAppApiBuilder = SpotifyAppApiBuilder ().apply {
176
+ credentials {
177
+ this .clientId = clientId
178
+ this .clientSecret = clientSecret
179
+ }
180
+ }
181
+
138
182
/* *
139
183
* Instantiate a new [SpotifyAppApiBuilder] using a Spotify [clientId] and [clientSecret], with the ability to configure
140
184
* the api settings by providing a builder initialization [block]
@@ -251,6 +295,35 @@ public fun spotifyAppApi(block: SpotifyAppApiBuilder.() -> Unit): SpotifyAppApiB
251
295
|| ||
252
296
*/
253
297
298
+ /* *
299
+ * Instantiate a new [SpotifyClientApiBuilder] using a Spotify [clientId], [clientSecret], and [redirectUri].
300
+ *
301
+ * **Note**: If trying to build [SpotifyClientApi], you **must** provide client authorization in the [SpotifyClientApiBuilder.authorization]
302
+ * block
303
+ *
304
+ * Use case: I am using the client authorization flow.
305
+ * I want access to both public and client Spotify API endpoints, and I want
306
+ * to configure authorization and other settings myself.
307
+ *
308
+ * @param clientId Spotify [client id](https://developer.spotify.com/documentation/general/guides/app-settings/)
309
+ * @param clientSecret Spotify [client secret](https://developer.spotify.com/documentation/general/guides/app-settings/)
310
+ * @param redirectUri Spotify [redirect uri](https://developer.spotify.com/documentation/general/guides/app-settings/)
311
+ *
312
+ * @return Configurable [SpotifyClientApiBuilder] that, when built, creates a new [SpotifyClientApi]
313
+ */
314
+ public fun spotifyClientApi (
315
+ clientId : String ,
316
+ clientSecret : String ,
317
+ redirectUri : String
318
+ ): SpotifyClientApiBuilder = SpotifyClientApiBuilder ().apply {
319
+ credentials {
320
+ this .clientId = clientId
321
+ this .clientSecret = clientSecret
322
+ this .redirectUri = redirectUri
323
+ }
324
+ }
325
+
326
+
254
327
/* *
255
328
* Instantiate a new [SpotifyClientApiBuilder] using a Spotify [clientId], [clientSecret], and [redirectUri], with the ability to configure
256
329
* the api settings by providing a builder initialization [block]
@@ -273,7 +346,7 @@ public fun spotifyClientApi(
273
346
clientId : String ,
274
347
clientSecret : String ,
275
348
redirectUri : String ,
276
- block : SpotifyClientApiBuilder .() -> Unit = {}
349
+ block : SpotifyClientApiBuilder .() -> Unit
277
350
): SpotifyClientApiBuilder = SpotifyClientApiBuilder ().apply (block).apply {
278
351
credentials {
279
352
this .clientId = clientId
@@ -411,6 +484,37 @@ public fun spotifyClientPkceApi(
411
484
usesPkceAuth = true
412
485
}
413
486
487
+ /* *
488
+ * Instantiate a new [SpotifyClientApiBuilder]. This is for **PKCE authorization**.
489
+ *
490
+ * Use case: I am using the PKCE client authorization flow.
491
+ *
492
+ * @param clientId Spotify [client id](https://developer.spotify.com/documentation/general/guides/app-settings/)
493
+ * @param redirectUri Spotify [redirect uri](https://developer.spotify.com/documentation/general/guides/app-settings/)
494
+ * @param pkceCodeVerifier The code verifier generated that the client authenticated with (using its code challenge)
495
+ * @param authorizationCode Only available when building [SpotifyClientApi]. Spotify auth code
496
+ *
497
+ * @return Configurable [SpotifyClientApiBuilder] that, when built, creates a new [SpotifyClientApi]
498
+ */
499
+ public fun spotifyClientPkceApi (
500
+ clientId : String? ,
501
+ redirectUri : String? ,
502
+ authorizationCode : String ,
503
+ pkceCodeVerifier : String
504
+ ): SpotifyClientApiBuilder = SpotifyClientApiBuilder ().apply {
505
+ credentials {
506
+ this .clientId = clientId
507
+ this .redirectUri = redirectUri
508
+ }
509
+
510
+ authorization {
511
+ this .authorizationCode = authorizationCode
512
+ this .pkceCodeVerifier = pkceCodeVerifier
513
+ }
514
+
515
+ usesPkceAuth = true
516
+ }
517
+
414
518
/* *
415
519
* Instantiate a new [SpotifyClientApiBuilder]. This is for **PKCE authorization**.
416
520
*
@@ -429,7 +533,7 @@ public fun spotifyClientPkceApi(
429
533
redirectUri : String? ,
430
534
authorizationCode : String ,
431
535
pkceCodeVerifier : String ,
432
- block : SpotifyApiOptions .() -> Unit = {}
536
+ block : SpotifyApiOptions .() -> Unit
433
537
): SpotifyClientApiBuilder = SpotifyClientApiBuilder ().apply {
434
538
credentials {
435
539
this .clientId = clientId
0 commit comments