Skip to content

Commit 15c41ee

Browse files
authored
Merge pull request #208 from adamint/feature/pkce-auth
add pkce auth
2 parents cb0022d + 8f6c421 commit 15c41ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+677
-367
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ If you have a question, you can:
6767

6868
## Creating a new api instance
6969
To decide which api you need (SpotifyAppApi, SpotifyClientApi, SpotifyImplicitGrantApi), please refer to
70-
https://developer.com.adamratzman.spotify.com/documentation/general/guides/authorization-guide/. In general:
70+
https://developer.spotify.com/documentation/general/guides/authorization-guide/. In general:
7171
- If you don't need client resources, use SpotifyAppApi
7272
- If you're using the api in a backend application, use SpotifyClientApi
7373
- If you're using the api in a frontend application, use SpotifyImplicitGrantApi

build.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ buildscript {
3131
}
3232

3333
group = "com.adamratzman"
34-
version = "3.2.0"
34+
version = "3.2.01"
3535

3636
/*java {
3737
withSourcesJar()
@@ -165,6 +165,7 @@ kotlin {
165165
implementation("org.spekframework.spek2:spek-dsl-jvm:$spekVersion")
166166
runtimeOnly("org.spekframework.spek2:spek-runner-junit5:$spekVersion")
167167
runtimeOnly(kotlin("reflect"))
168+
implementation("com.sparkjava:spark-core:2.9.1")
168169
}
169170
}
170171

@@ -176,7 +177,7 @@ kotlin {
176177
api("io.ktor:ktor-client-js:$ktorVersion")
177178
api(npm("abort-controller", "3.0.0"))
178179
api(npm("node-fetch", "2.6.0"))
179-
180+
api(npm("btoa", "1.2.1"))
180181
compileOnly(kotlin("stdlib-js"))
181182
}
182183
}

samples/jvm/src/main/kotlin/appApi/AlbumApiSample.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ fun main() {
1111
).build()
1212

1313
// get album "Kids in Love" by the Mowgli's release date
14-
println(api.albums.getAlbum("com.adamratzman.spotify:album:4M2p2BIRHIeBu8Ew9IBQ0s").complete()!!.releaseDate)
14+
println(api.albums.getAlbum("spotify:album:4M2p2BIRHIeBu8Ew9IBQ0s").complete()!!.releaseDate)
1515

1616
// get album "Kids in Love" and a non-existant album
17-
println(api.albums.getAlbums("com.adamratzman.spotify:album:4M2p2BIRHIeBu8Ew9IBQ0s", "nonexistantalbum"))
17+
println(api.albums.getAlbums("spotify:album:4M2p2BIRHIeBu8Ew9IBQ0s", "nonexistantalbum"))
1818

1919
// get album "Kids in Love"'s tracks
20-
println(api.albums.getAlbumTracks("com.adamratzman.spotify:album:4M2p2BIRHIeBu8Ew9IBQ0s").complete().filterNotNull().map { it.name })
20+
println(api.albums.getAlbumTracks("spotify:album:4M2p2BIRHIeBu8Ew9IBQ0s").complete().filterNotNull().map { it.name })
2121
}

samples/jvm/src/main/kotlin/appApi/ArtistApiSample.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ fun main() {
1111
).build()
1212

1313
// get artist Cody G's total follower count
14-
println(api.artists.getArtist("com.adamratzman.spotify:artist:26HkLAAIMh5qOFet57d1rg").complete()!!.followers.total)
14+
println(api.artists.getArtist("spotify:artist:26HkLAAIMh5qOFet57d1rg").complete()!!.followers.total)
1515

1616
// get artist Cody G and a non-existant artist
17-
println(api.artists.getArtists("com.adamratzman.spotify:artist:26HkLAAIMh5qOFet57d1rg", "nonexistantartist"))
17+
println(api.artists.getArtists("spotify:artist:26HkLAAIMh5qOFet57d1rg", "nonexistantartist"))
1818

1919
// get all of artist Cody G's albums
20-
println(api.artists.getArtistAlbums("com.adamratzman.spotify:artist:26HkLAAIMh5qOFet57d1rg").getAllItems().complete().filterNotNull().map { it.name })
20+
println(api.artists.getArtistAlbums("spotify:artist:26HkLAAIMh5qOFet57d1rg").getAllItems().complete().filterNotNull().map { it.name })
2121

2222
// get Cody G's top tracks, in descending order, in France
23-
println(api.artists.getArtistTopTracks("com.adamratzman.spotify:artist:26HkLAAIMh5qOFet57d1rg").complete().map { it.name })
23+
println(api.artists.getArtistTopTracks("spotify:artist:26HkLAAIMh5qOFet57d1rg").complete().map { it.name })
2424

2525
// get Cody G's related artists
26-
println(api.artists.getRelatedArtists("com.adamratzman.spotify:artist:26HkLAAIMh5qOFet57d1rg").complete().map { it.name })
26+
println(api.artists.getRelatedArtists("spotify:artist:26HkLAAIMh5qOFet57d1rg").complete().map { it.name })
2727
}

samples/jvm/src/main/kotlin/appApi/BrowseApiSample.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fun main() {
3939

4040
// get and print recommendation seeds and tracks
4141
val recommendationResponse = api.browse.getTrackRecommendations(
42-
seedTracks = listOf("com.adamratzman.spotify:track:2LYAG9jlH9rul11nalRxR0"),
42+
seedTracks = listOf("spotify:track:2LYAG9jlH9rul11nalRxR0"),
4343
seedGenres = listOf("indie-pop"),
4444
minAttributes = listOf(TrackAttribute.create(TuneableTrackAttribute.Danceability, 0.6f))
4545
).complete()

samples/jvm/src/main/kotlin/appApi/FollowingApiSample.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ fun main() {
1111
).build()
1212

1313
// check if adamratzman and adamratzman1 are following "Hit Rewind"
14-
println(api.following.areFollowingPlaylist("com.adamratzman.spotify:playlist:37i9dQZF1DX0s5kDXi1oC5", "adamratzman", "adamratzman1"))
14+
println(api.following.areFollowingPlaylist("spotify:playlist:37i9dQZF1DX0s5kDXi1oC5", "adamratzman", "adamratzman1"))
1515

1616
// check if adamratzman1 is following "Hit Rewind"
17-
println(api.following.isFollowingPlaylist("com.adamratzman.spotify:playlist:37i9dQZF1DX0s5kDXi1oC5", "adamratzman1"))
17+
println(api.following.isFollowingPlaylist("spotify:playlist:37i9dQZF1DX0s5kDXi1oC5", "adamratzman1"))
1818
}

samples/jvm/src/main/kotlin/appApi/PlaylistApiSample.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ fun main() {
1616
println(api.playlists.getUserPlaylists("adamratzman1").getAllItems().complete().filterNotNull().map { it.name })
1717

1818
// get playlist "Hit Rewind"'s description in Andorra's market
19-
println(api.playlists.getPlaylist("com.adamratzman.spotify:playlist:37i9dQZF1DX0s5kDXi1oC5", Market.AD).complete()!!.description)
19+
println(api.playlists.getPlaylist("spotify:playlist:37i9dQZF1DX0s5kDXi1oC5", Market.AD).complete()!!.description)
2020

2121
// get up to 20 tracks for playlist "Hit Rewind"
22-
println(api.playlists.getPlaylistTracks("com.adamratzman.spotify:playlist:37i9dQZF1DX0s5kDXi1oC5").complete().items.map { (it.track as Track).name })
22+
println(api.playlists.getPlaylistTracks("spotify:playlist:37i9dQZF1DX0s5kDXi1oC5").complete().items.map { (it.track as Track).name })
2323

2424
// get playlist covers for "Hit Rewind"
25-
println(api.playlists.getPlaylistCovers("com.adamratzman.spotify:playlist:37i9dQZF1DX0s5kDXi1oC5").complete())
25+
println(api.playlists.getPlaylistCovers("spotify:playlist:37i9dQZF1DX0s5kDXi1oC5").complete())
2626
}

samples/jvm/src/main/kotlin/appApi/TrackApiSample.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ fun main() {
1111
).build()
1212

1313
// get track "I'm Good" by the Mowgli's and check its popularity
14-
println(api.tracks.getTrack("com.adamratzman.spotify:track:5KQDGl3vAkNGyfvSbaW89E").complete()!!.popularity)
14+
println(api.tracks.getTrack("spotify:track:5KQDGl3vAkNGyfvSbaW89E").complete()!!.popularity)
1515

1616
// get track "I'm Good" and a non-existant track
17-
println(api.tracks.getTracks("com.adamratzman.spotify:track:5KQDGl3vAkNGyfvSbaW89E", "nonexistanttrack").complete())
17+
println(api.tracks.getTracks("spotify:track:5KQDGl3vAkNGyfvSbaW89E", "nonexistanttrack").complete())
1818

1919
// get audio analysis for track "I'm Good"
20-
println(api.tracks.getAudioAnalysis("com.adamratzman.spotify:track:5KQDGl3vAkNGyfvSbaW89E").complete())
20+
println(api.tracks.getAudioAnalysis("spotify:track:5KQDGl3vAkNGyfvSbaW89E").complete())
2121

2222
// get audio features for track "I'm Good"
23-
println(api.tracks.getAudioFeatures("com.adamratzman.spotify:track:5KQDGl3vAkNGyfvSbaW89E").complete())
23+
println(api.tracks.getAudioFeatures("spotify:track:5KQDGl3vAkNGyfvSbaW89E").complete())
2424

2525
// get audio features for an existing and non-existant track
26-
println(api.tracks.getAudioFeatures("com.adamratzman.spotify:track:5KQDGl3vAkNGyfvSbaW89E", "nonexistanttrack"))
26+
println(api.tracks.getAudioFeatures("spotify:track:5KQDGl3vAkNGyfvSbaW89E", "nonexistanttrack"))
2727
}

samples/jvm/src/main/kotlin/clientApi/ClientFollowingApiSample.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,25 @@ fun main() {
1616
.build()
1717

1818
// see if you're following playlist "I'm Good Radio"
19-
println(api.following.isFollowingPlaylist("com.adamratzman.spotify:playlist:37i9dQZF1E8L0j2hm3kP31").complete())
19+
println(api.following.isFollowingPlaylist("spotify:playlist:37i9dQZF1E8L0j2hm3kP31").complete())
2020

2121
// see if you're following users adamratzman1 and adamratzman
2222
println(api.following.isFollowingUsers("adamratzman1", "adamratzman").complete())
2323

2424
// see if you're following artist Louane
25-
println(api.following.isFollowingArtist("com.adamratzman.spotify:artist:7wjeXCtRND2ZdKfMJFu6JC").complete())
25+
println(api.following.isFollowingArtist("spotify:artist:7wjeXCtRND2ZdKfMJFu6JC").complete())
2626

2727
// get all followed artists, limiting 1 each request
2828
println(api.following.getFollowedArtists(limit = 1).getAllItems().complete())
2929

3030
// follow and unfollow, if you weren't previously following, the artist Louane
3131

32-
val isFollowingLouane = api.following.isFollowingArtist("com.adamratzman.spotify:artist:7wjeXCtRND2ZdKfMJFu6JC").complete()
32+
val isFollowingLouane = api.following.isFollowingArtist("spotify:artist:7wjeXCtRND2ZdKfMJFu6JC").complete()
3333

34-
if (isFollowingLouane) api.following.unfollowArtist("com.adamratzman.spotify:artist:7wjeXCtRND2ZdKfMJFu6JC").complete()
35-
api.following.followArtist("com.adamratzman.spotify:artist:7wjeXCtRND2ZdKfMJFu6JC").complete()
34+
if (isFollowingLouane) api.following.unfollowArtist("spotify:artist:7wjeXCtRND2ZdKfMJFu6JC").complete()
35+
api.following.followArtist("spotify:artist:7wjeXCtRND2ZdKfMJFu6JC").complete()
3636

37-
if (!isFollowingLouane) api.following.unfollowArtist("com.adamratzman.spotify:artist:7wjeXCtRND2ZdKfMJFu6JC").complete()
37+
if (!isFollowingLouane) api.following.unfollowArtist("spotify:artist:7wjeXCtRND2ZdKfMJFu6JC").complete()
3838

3939
// follow and unfollow, if you weren't previously following, the user adamratzman1
4040

@@ -47,10 +47,10 @@ fun main() {
4747

4848
// follow and unfollow, if you weren't previously following, the playlist Today's Top Hits
4949

50-
val isFollowingTodaysTopHits = api.following.isFollowingPlaylist("com.adamratzman.spotify:playlist:37i9dQZF1DXcBWIGoYBM5M").complete()
50+
val isFollowingTodaysTopHits = api.following.isFollowingPlaylist("spotify:playlist:37i9dQZF1DXcBWIGoYBM5M").complete()
5151

52-
if (isFollowingTodaysTopHits) api.following.unfollowPlaylist("com.adamratzman.spotify:playlist:37i9dQZF1DXcBWIGoYBM5M").complete()
53-
api.following.followPlaylist("com.adamratzman.spotify:playlist:37i9dQZF1DXcBWIGoYBM5M").complete()
52+
if (isFollowingTodaysTopHits) api.following.unfollowPlaylist("spotify:playlist:37i9dQZF1DXcBWIGoYBM5M").complete()
53+
api.following.followPlaylist("spotify:playlist:37i9dQZF1DXcBWIGoYBM5M").complete()
5454

55-
if (!isFollowingTodaysTopHits) api.following.unfollowPlaylist("com.adamratzman.spotify:playlist:37i9dQZF1DXcBWIGoYBM5M").complete()
55+
if (!isFollowingTodaysTopHits) api.following.unfollowPlaylist("spotify:playlist:37i9dQZF1DXcBWIGoYBM5M").complete()
5656
}

samples/jvm/src/main/kotlin/clientApi/ClientLibraryApiSample.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ fun main() {
2424
println(api.library.contains(TRACK, api.search.searchTrack("I'm Good the Mowgli's").complete()[0].id).complete())
2525

2626
// add and remove track "Up" by Nav
27-
api.library.add(TRACK, "com.adamratzman.spotify:track:5qbcsZMwL0x46sX7VO37Ye").complete()
28-
api.library.remove(TRACK, "com.adamratzman.spotify:track:5qbcsZMwL0x46sX7VO37Ye").complete()
27+
api.library.add(TRACK, "spotify:track:5qbcsZMwL0x46sX7VO37Ye").complete()
28+
api.library.remove(TRACK, "spotify:track:5qbcsZMwL0x46sX7VO37Ye").complete()
2929
}

0 commit comments

Comments
 (0)