Skip to content

Commit bc7f9ea

Browse files
authored
Merge pull request #212 from adamint/dev
fix android base64, pkce
2 parents 6a7da3e + ef93418 commit bc7f9ea

Some content is hidden

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

53 files changed

+820
-1178
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ email, or any other method with the owners of this repository before making a ch
55

66
Please note we have a code of conduct, please follow it in all your interactions with the project.
77

8+
89
## Testing
910
Please see [testing.md](TESTING.md) for full testing instructions. Your contributions should be able to pass every test
1011

README.md

Lines changed: 266 additions & 65 deletions
Large diffs are not rendered by default.

TESTING.md

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,20 @@ You must create a Spotify application [here](https://developer.spotify.com/dashb
77

88
To run **only** public endpoint tests, run
99

10-
`gradle check`
10+
`gradle jvmTest` and `gradle testDebugUnitTest`
1111

1212
Note: You must have `SPOTIFY_CLIENT_ID` and `SPOTIFY_CLIENT_SECRET` as environment variables.
1313

1414
To run **all** tests, you need a valid Spotify application, redirect uri, and token string. use:
1515

16-
`gradle check`
16+
`gradle jvmTest` and `gradle testDebugUnitTest`
1717

1818
Note: In addition to `SPOTIFY_CLIENT_ID` and `SPOTIFY_CLIENT_SECRET`, you also must have the following environment
1919
variables set up: `SPOTIFY_REDIRECT_URI` and `SPOTIFY_TOKEN_STRING`
2020

2121
Some tests may fail if you do not allow access to all required scopes. To mitigate this, you can individually grant
2222
each scope or use the following code snippet to print out the Spotify token string (given a generated authorization code)
2323

24-
**How to generate an authorization URL**
25-
```kotlin
26-
import com.adamratzman.com.adamratzman.spotify.main.SpotifyScope
27-
val api = spotifyClientApi(
28-
"SPOTIFY_CLIENT_ID",
29-
"SPOTIFY_CLIENT_SECRET",
30-
"SPOTIFY_REDIRECT_URI") {
31-
authorization {
32-
tokenString = "SPOTIFY_TOKEN_STRING"
33-
}
34-
}.getAuthorizationUrl(*SpotifyScope.values())
35-
36-
```
37-
38-
**How to get a Spotify token**
39-
```kotlin
40-
val api = spotifyClientApi(
41-
"SPOTIFY_CLIENT_ID",
42-
"SPOTIFY_CLIENT_SECRET",
43-
"SPOTIFY_REDIRECT_URI") {
44-
authorization {
45-
tokenString = "SPOTIFY_TOKEN_STRING"
46-
}
47-
}.build().token.accessToken.let { println(it) }
48-
```
24+
To build the maven artifact locally, you will need to follow these steps:
25+
- Create `gradle.properties` if it doesn't exist already.
26+
- Follow [this guide](https://gist.github.com/phit/bd3c6d156a2fa5f3b1bc15fa94b3256c). Instead of `.gpg` extension, use `.kbx` for your secring.

build.gradle.kts

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

3333
group = "com.adamratzman"
34-
version = "3.2.01"
35-
36-
/*java {
37-
withSourcesJar()
38-
withJavadocJar()
39-
}
40-
*/
34+
version = "3.2.11"
4135

4236
tasks.withType<Test> {
4337
this.testLogging {
@@ -47,6 +41,13 @@ tasks.withType<Test> {
4741

4842
android {
4943
compileSdkVersion(30)
44+
compileOptions {
45+
sourceCompatibility = JavaVersion.VERSION_1_8
46+
targetCompatibility = JavaVersion.VERSION_1_8
47+
}
48+
packagingOptions {
49+
exclude("META-INF/*.md")
50+
}
5051
defaultConfig {
5152
minSdkVersion(15)
5253
targetSdkVersion(30)
@@ -59,13 +60,19 @@ android {
5960
isMinifyEnabled = false
6061
}
6162
}
63+
testOptions {
64+
@Suppress("UNCHECKED_CAST")
65+
this.unitTests.all(closureOf<Test> {
66+
this.useJUnitPlatform()
67+
} as groovy.lang.Closure<Test>)
68+
}
6269
sourceSets {
6370
getByName("main") {
6471
manifest.srcFile("src/androidMain/AndroidManifest.xml")
6572
java.setSrcDirs(listOf("src/androidMain/kotlin"))
6673
res.setSrcDirs(listOf("src/androidMain/res"))
6774
}
68-
getByName("androidTest") {
75+
getByName("test") {
6976
java.setSrcDirs(listOf("src/androidTest/kotlin"))
7077
res.setSrcDirs(listOf("src/androidTest/res"))
7178
}
@@ -86,7 +93,9 @@ kotlin {
8693
setupPom(artifactId)
8794
}
8895

89-
publishLibraryVariants("release")
96+
publishLibraryVariants("debug", "release")
97+
98+
publishLibraryVariantsGroupedByFlavor = true
9099
}
91100

92101
jvm {
@@ -152,7 +161,7 @@ kotlin {
152161
dependencies {
153162
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion")
154163
api("org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion")
155-
api("io.ktor:ktor-client-okhttp:$ktorVersion")
164+
api("io.ktor:ktor-client-cio:$ktorVersion")
156165
implementation(kotlin("stdlib-jdk8"))
157166
}
158167
}
@@ -162,10 +171,10 @@ kotlin {
162171
implementation(kotlin("test"))
163172
implementation(kotlin("test-junit"))
164173
implementation("org.junit.jupiter:junit-jupiter:5.6.2")
174+
implementation("com.sparkjava:spark-core:2.9.1")
165175
implementation("org.spekframework.spek2:spek-dsl-jvm:$spekVersion")
166176
runtimeOnly("org.spekframework.spek2:spek-runner-junit5:$spekVersion")
167177
runtimeOnly(kotlin("reflect"))
168-
implementation("com.sparkjava:spark-core:2.9.1")
169178
}
170179
}
171180

@@ -177,7 +186,7 @@ kotlin {
177186
api("io.ktor:ktor-client-js:$ktorVersion")
178187
api(npm("abort-controller", "3.0.0"))
179188
api(npm("node-fetch", "2.6.0"))
180-
api(npm("btoa", "1.2.1"))
189+
181190
compileOnly(kotlin("stdlib-js"))
182191
}
183192
}
@@ -199,7 +208,8 @@ kotlin {
199208
api("net.sourceforge.streamsupport:android-retrofuture:1.7.2")
200209
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion")
201210
api("org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion")
202-
api("io.ktor:ktor-client-okhttp:$ktorVersion")
211+
api("io.ktor:ktor-client-cio:$ktorVersion")
212+
api("io.coil-kt:coil:0.11.0")
203213
implementation(kotlin("stdlib-jdk8"))
204214
}
205215
}
@@ -209,6 +219,8 @@ kotlin {
209219
implementation(kotlin("test"))
210220
implementation(kotlin("test-junit"))
211221
implementation("org.junit.jupiter:junit-jupiter:5.6.2")
222+
implementation("com.sparkjava:spark-core:2.9.1")
223+
implementation("org.mockito:mockito-core:3.3.3")
212224
implementation("org.spekframework.spek2:spek-dsl-jvm:$spekVersion")
213225
runtimeOnly("org.spekframework.spek2:spek-runner-junit5:$spekVersion")
214226
runtimeOnly(kotlin("reflect"))
@@ -253,7 +265,11 @@ publishing {
253265
}
254266

255267
signing {
256-
sign(publishing.publications)
268+
if (project.hasProperty("signing.keyId")
269+
&& project.hasProperty("signing.password")
270+
&& project.hasProperty("signing.secretKeyRingFile")) {
271+
sign(publishing.publications)
272+
}
257273
}
258274

259275
tasks {
@@ -265,30 +281,30 @@ tasks {
265281
val js by creating {
266282
sourceLink {
267283
path = "/src"
268-
url = "https://github.com/adamint/com.adamratzman.spotify-web-api-kotlin/tree/master/"
284+
url = "https://github.com/adamint/spotify-web-api-kotlin/tree/master/"
269285
lineSuffix = "#L"
270286
}
271287
}
272288
val jvm by creating {
273289
sourceLink {
274290
path = "/src"
275-
url = "https://github.com/adamint/com.adamratzman.spotify-web-api-kotlin/tree/master/"
291+
url = "https://github.com/adamint/spotify-web-api-kotlin/tree/master/"
276292
lineSuffix = "#L"
277293
}
278294
}
279295

280296
register("common") {
281297
sourceLink {
282298
path = "/src"
283-
url = "https://github.com/adamint/com.adamratzman.spotify-web-api-kotlin/tree/master/"
299+
url = "https://github.com/adamint/spotify-web-api-kotlin/tree/master/"
284300
lineSuffix = "#L"
285301
}
286302
}
287303

288304
register("global") {
289305
sourceLink {
290306
path = "/src"
291-
url = "https://github.com/adamint/com.adamratzman.spotify-web-api-kotlin/tree/master/"
307+
url = "https://github.com/adamint/spotify-web-api-kotlin/tree/master/"
292308
lineSuffix = "#L"
293309
}
294310

@@ -302,12 +318,6 @@ tasks {
302318
}
303319
}
304320

305-
/* val javadocJar by getting(Jar::class) {
306-
dependsOn.add(javadoc)
307-
archiveClassifier.set("javadoc")
308-
from(javadoc)
309-
}*/
310-
311321
spotless {
312322
kotlin {
313323
target("**/*.kt")
@@ -325,7 +335,6 @@ tasks {
325335
useJUnitPlatform()
326336
}
327337

328-
329338
val publishJvm by registering(Task::class) {
330339
dependsOn.add(check)
331340
dependsOn.add(dokka)
@@ -341,12 +350,12 @@ fun MavenPublication.setupPom(publicationName: String) {
341350
pom {
342351
name.set(publicationName)
343352
description.set("A Kotlin wrapper for the Spotify Web API.")
344-
url.set("https://github.com/adamint/com.adamratzman.spotify-web-api-kotlin")
353+
url.set("https://github.com/adamint/spotify-web-api-kotlin")
345354
inceptionYear.set("2018")
346355
scm {
347-
url.set("https://github.com/adamint/com.adamratzman.spotify-web-api-kotlin")
348-
connection.set("scm:https://github.com/adamint/com.adamratzman.spotify-web-api-kotlin.git")
349-
developerConnection.set("scm:git://github.com/adamint/com.adamratzman.spotify-web-api-kotlin.git")
356+
url.set("https://github.com/adamint/spotify-web-api-kotlin")
357+
connection.set("scm:https://github.com/adamint/spotify-web-api-kotlin.git")
358+
developerConnection.set("scm:git://github.com/adamint/spotify-web-api-kotlin.git")
350359
}
351360
licenses {
352361
license {

gradle/wrapper/gradle-wrapper.jar

-57.5 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 0 additions & 5 deletions
This file was deleted.

gradlew

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ esac
8282

8383
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
8484

85-
8685
# Determine the Java command to use to start the JVM.
8786
if [ -n "$JAVA_HOME" ] ; then
8887
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -130,7 +129,6 @@ fi
130129
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131130
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132131
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133-
134132
JAVACMD=`cygpath --unix "$JAVACMD"`
135133

136134
# We build the pattern for arguments to be converted via cygpath

gradlew.bat

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ if "%DIRNAME%" == "" set DIRNAME=.
2929
set APP_BASE_NAME=%~n0
3030
set APP_HOME=%DIRNAME%
3131

32-
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
33-
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34-
3532
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
3633
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
3734

@@ -84,7 +81,6 @@ set CMD_LINE_ARGS=%*
8481

8582
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
8683

87-
8884
@rem Execute Gradle
8985
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
9086

samples/jvm/build.gradle

Lines changed: 0 additions & 23 deletions
This file was deleted.
-53.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)