You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -193,18 +193,18 @@ the code challenge used to authorize the user.
193
193
194
194
This library contains helpful methods that can be used to simplify the PKCE authorization process.
195
195
This includes `getSpotifyPkceCodeChallenge`, which SHA256 hashes and base64url encodes the code
196
-
challenge, and `getPkceAuthorizationUrl`, which allows you to generate an easy authorization url for PKCE flow.
196
+
challenge, and `getSpotifyPkceAuthorizationUrl`, which allows you to generate an easy authorization url for PKCE flow.
197
197
198
198
Please see the [spotifyClientPkceApi builder docs](https://adamint.github.io/spotify-web-api-kotlin-docs/spotify-web-api-kotlin/com.adamratzman.spotify/spotify-client-pkce-api.html) for a full list of available builders.
199
199
200
200
**Takeaway**: Use PKCE authorization flow in applications where you cannot secure the client secret.
201
201
202
-
To get a PKCE authorization url, to which you can redirect a user, you can use the `getPkceAuthorizationUrl`
202
+
To get a PKCE authorization url, to which you can redirect a user, you can use the `getSpotifyPkceAuthorizationUrl`
203
203
top-level method. An example is shown below, requesting 4 different scopes.
204
204
```kotlin
205
205
val codeVerifier ="thisisaveryrandomalphanumericcodeverifierandisgreaterthan43characters"
206
206
val codeChallenge = getSpotifyPkceCodeChallenge(codeVerifier) // helper method
Copy file name to clipboardExpand all lines: src/androidMain/kotlin/com/adamratzman/spotify/auth/implicit/AbstractSpotifyAppCompatImplicitLoginActivity.kt
+2-3
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
1
+
/* Spotify Web API, Kotlin Wrapper; MIT License, 2017-2021; Original author: Adam Ratzman */
1
2
packagecom.adamratzman.spotify.auth.implicit
2
3
3
4
importandroid.app.Activity
@@ -17,16 +18,14 @@ public abstract class AbstractSpotifyAppCompatImplicitLoginActivity : SpotifyImp
Copy file name to clipboardExpand all lines: src/androidMain/kotlin/com/adamratzman/spotify/auth/implicit/SpotifyImplicitLoginActivity.kt
+4-6
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
1
+
/* Spotify Web API, Kotlin Wrapper; MIT License, 2017-2021; Original author: Adam Ratzman */
1
2
packagecom.adamratzman.spotify.auth.implicit
2
3
3
4
importandroid.app.Activity
@@ -52,7 +53,6 @@ public interface SpotifyImplicitLoginActivity {
52
53
*/
53
54
publicfunonFailure(errorMessage:String)
54
55
55
-
56
56
/**
57
57
* Override this to define what to do after [onSuccess] has run.
58
58
* The default behavior is to finish the activity, and redirect the user back to the activity set on [SpotifyDefaultCredentialStore.activityBackOnImplicitAuth]
@@ -90,7 +90,7 @@ public interface SpotifyImplicitLoginActivity {
90
90
val token =Token(
91
91
response.accessToken,
92
92
response.type.name,
93
-
response.expiresIn,
93
+
response.expiresIn
94
94
)
95
95
val api = spotifyImplicitGrantApi(
96
96
clientId = clientId,
@@ -101,7 +101,7 @@ public interface SpotifyImplicitLoginActivity {
101
101
redirectAfterOnSuccessAuthentication()
102
102
}
103
103
// AuthorizationResponse.Type.CODE -> TODO()
104
-
//AuthorizationResponse.Type.UNKNOWN -> TODO()
104
+
//AuthorizationResponse.Type.UNKNOWN -> TODO()
105
105
AuthorizationResponse.Type.ERROR-> {
106
106
logToConsole("Got error in authorization... executing error handler")
* This class hooks into spotify-web-api-kotlin to provide PKCE authorization for Android application. Paired with [SpotifyDefaultCredentialStore] to easily store credentials.
@@ -59,7 +60,7 @@ public abstract class AbstractSpotifyPkceLoginActivity : AppCompatActivity() {
59
60
/**
60
61
* Get the authorization url that the client will be redirected to during PKCE authorization.
@@ -122,7 +121,7 @@ public data class SpotifyMetadataChangedData(
122
121
* A playback state change is sent whenever the user presses play/pause, or when seeking the track position. It uses the intent action com.spotify.music.playbackstatechanged.
123
122
*
124
123
* @param playing True if playing, false if paused.
125
-
* @param positionInMs The current playback position in milliseconds.
124
+
* @param positionInMs The current playback position in milliseconds.
126
125
* @param timeSentInMs When the notification was sent.
0 commit comments