Skip to content

Commit

Permalink
Hotfix KtifyBuilder URL generation (#7)
Browse files Browse the repository at this point in the history
* Hotfix KtifyBuilder URL generation

* Edit version in README
  • Loading branch information
warriorzz authored May 8, 2024
1 parent c4cf3a8 commit d5f340c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repositories {
mavenCentral()
}
dependencies {
implementation("ee.bjarn", "ktify", "0.1.1")
implementation("ee.bjarn", "ktify", "0.1.1-hotfix")
}
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {
}

group = "ee.bjarn"
version = "0.1.1"
version = "0.1.1-hotfix"

repositories {
mavenCentral()
Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/ee/bjarn/ktify/Ktify.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import io.ktor.serialization.kotlinx.json.*
import io.ktor.util.*
import kotlinx.serialization.json.JsonObject
import mu.KotlinLogging
import java.net.URLEncoder
import java.util.UUID

/**
Expand Down Expand Up @@ -103,8 +104,8 @@ class KtifyBuilder(
*/
fun getAuthorisationURL(scopes: List<Scope>): String {
val baseUrl = "https://accounts.spotify.com/authorize"
val scopesString = if (scopes.size > 0) scopes.map { it.value + "%20" }.reduce { acc, s -> acc + s }.dropLast(3) else "none"
return "$baseUrl?client_id=&scope=$scopesString&redirect_uri=$redirectUri&state=$state&response_type=code"
val scopesString = if (scopes.size > 0) scopes.map { it.value + " " }.reduce { acc, s -> acc + s }.dropLast(1) else "none"
return "$baseUrl?client_id=$clientId&scope=${URLEncoder.encode(scopesString, "UTF-8")}&redirect_uri=${URLEncoder.encode(redirectUri, "UTF-8")}&state=$state&response_type=code"
}

/**
Expand Down

0 comments on commit d5f340c

Please sign in to comment.