@@ -127,7 +127,8 @@ fun spotifyImplicitGrantApi(
127
127
options.defaultLimit,
128
128
options.allowBulkRequests,
129
129
options.requestTimeoutMillis,
130
- options.json
130
+ options.json,
131
+ options.requiredScopes
131
132
)
132
133
133
134
// App Api builders
@@ -834,7 +835,8 @@ class SpotifyClientApiBuilder(
834
835
options.json,
835
836
options.refreshTokenProducer,
836
837
false ,
837
- options.onTokenRefresh
838
+ options.onTokenRefresh,
839
+ options.requiredScopes
838
840
)
839
841
} catch (e: CancellationException ) {
840
842
throw e
@@ -877,7 +879,8 @@ class SpotifyClientApiBuilder(
877
879
options.json,
878
880
options.refreshTokenProducer,
879
881
true ,
880
- options.onTokenRefresh
882
+ options.onTokenRefresh,
883
+ options.requiredScopes
881
884
)
882
885
} catch (e: CancellationException ) {
883
886
throw e
@@ -901,7 +904,8 @@ class SpotifyClientApiBuilder(
901
904
options.json,
902
905
options.refreshTokenProducer,
903
906
authorization.pkceCodeVerifier != null ,
904
- options.onTokenRefresh
907
+ options.onTokenRefresh,
908
+ options.requiredScopes
905
909
)
906
910
authorization.tokenString != null -> SpotifyClientApi (
907
911
clientId,
@@ -926,7 +930,8 @@ class SpotifyClientApiBuilder(
926
930
options.json,
927
931
options.refreshTokenProducer,
928
932
false ,
929
- options.onTokenRefresh
933
+ options.onTokenRefresh,
934
+ options.requiredScopes
930
935
)
931
936
else -> throw IllegalArgumentException (
932
937
" At least one of: authorizationCode, tokenString, or token must be provided " +
@@ -972,7 +977,8 @@ class SpotifyAppApiBuilder(
972
977
options.requestTimeoutMillis,
973
978
options.json,
974
979
options.refreshTokenProducer,
975
- options.onTokenRefresh
980
+ options.onTokenRefresh,
981
+ options.requiredScopes
976
982
)
977
983
authorization.tokenString != null -> {
978
984
SpotifyAppApi (
@@ -993,7 +999,8 @@ class SpotifyAppApiBuilder(
993
999
options.requestTimeoutMillis,
994
1000
options.json,
995
1001
options.refreshTokenProducer,
996
- options.onTokenRefresh
1002
+ options.onTokenRefresh,
1003
+ options.requiredScopes
997
1004
)
998
1005
}
999
1006
authorization.refreshTokenString != null -> {
@@ -1012,7 +1019,8 @@ class SpotifyAppApiBuilder(
1012
1019
options.requestTimeoutMillis,
1013
1020
options.json,
1014
1021
options.refreshTokenProducer,
1015
- options.onTokenRefresh
1022
+ options.onTokenRefresh,
1023
+ options.requiredScopes
1016
1024
)
1017
1025
}
1018
1026
else -> try {
@@ -1033,7 +1041,8 @@ class SpotifyAppApiBuilder(
1033
1041
options.requestTimeoutMillis,
1034
1042
options.json,
1035
1043
options.refreshTokenProducer,
1036
- options.onTokenRefresh
1044
+ options.onTokenRefresh,
1045
+ options.requiredScopes
1037
1046
)
1038
1047
} catch (e: CancellationException ) {
1039
1048
throw e
@@ -1119,6 +1128,7 @@ data class SpotifyUserAuthorization(
1119
1128
* @property requestTimeoutMillis The maximum time, in milliseconds, before terminating an http request
1120
1129
* @property refreshTokenProducer Provide if you want to use your own logic when refreshing a Spotify token
1121
1130
* @property onTokenRefresh Provide if you want to act on token refresh event
1131
+ * @property requiredScopes Scopes that your application requires to function (only applicable to [SpotifyClientApi] and [SpotifyImplicitGrantApi]).
1122
1132
*
1123
1133
*/
1124
1134
class SpotifyApiOptionsBuilder (
@@ -1134,7 +1144,8 @@ class SpotifyApiOptionsBuilder(
1134
1144
var requestTimeoutMillis : Long? = null ,
1135
1145
var json : Json = nonstrictJson,
1136
1146
var refreshTokenProducer : (suspend (GenericSpotifyApi ) -> Token )? = null ,
1137
- var onTokenRefresh : (suspend (GenericSpotifyApi ) -> Unit )? = null
1147
+ var onTokenRefresh : (suspend (GenericSpotifyApi ) -> Unit )? = null ,
1148
+ var requiredScopes : List <SpotifyScope >? = null
1138
1149
) {
1139
1150
fun build () =
1140
1151
if (enableAllOptions)
@@ -1150,7 +1161,8 @@ class SpotifyApiOptionsBuilder(
1150
1161
requestTimeoutMillis = requestTimeoutMillis,
1151
1162
json = json,
1152
1163
refreshTokenProducer = refreshTokenProducer,
1153
- onTokenRefresh = onTokenRefresh
1164
+ onTokenRefresh = onTokenRefresh,
1165
+ requiredScopes = requiredScopes
1154
1166
)
1155
1167
else
1156
1168
SpotifyApiOptions (
@@ -1165,7 +1177,8 @@ class SpotifyApiOptionsBuilder(
1165
1177
requestTimeoutMillis,
1166
1178
json,
1167
1179
refreshTokenProducer,
1168
- onTokenRefresh
1180
+ onTokenRefresh,
1181
+ requiredScopes
1169
1182
)
1170
1183
}
1171
1184
@@ -1184,6 +1197,7 @@ class SpotifyApiOptionsBuilder(
1184
1197
* @property requestTimeoutMillis The maximum time, in milliseconds, before terminating an http request. Default: 100000ms
1185
1198
* @property refreshTokenProducer Provide if you want to use your own logic when refreshing a Spotify token.
1186
1199
* @property onTokenRefresh Provide if you want to act on token refresh event
1200
+ * @property requiredScopes Scopes that your application requires to function (only applicable to [SpotifyClientApi] and [SpotifyImplicitGrantApi]).
1187
1201
*
1188
1202
*/
1189
1203
@@ -1199,7 +1213,8 @@ data class SpotifyApiOptions(
1199
1213
var requestTimeoutMillis : Long? ,
1200
1214
var json : Json ,
1201
1215
var refreshTokenProducer : (suspend (SpotifyApi <* , * >) -> Token )? ,
1202
- var onTokenRefresh : (suspend (SpotifyApi <* , * >) -> Unit )?
1216
+ var onTokenRefresh : (suspend (SpotifyApi <* , * >) -> Unit )? ,
1217
+ var requiredScopes : List <SpotifyScope >?
1203
1218
)
1204
1219
1205
1220
@Deprecated(" Name has been replaced by `options`" , ReplaceWith (" SpotifyApiOptions" ))
0 commit comments