File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
src/androidMain/kotlin/com/adamratzman/spotify/auth Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,11 @@ public class SpotifyDefaultCredentialStore(
53
53
*/
54
54
public const val SpotifyRefreshTokenKey : String = " spotifyRefreshToken"
55
55
56
+ /* *
57
+ * The PKCE code verifier key currently being used in [EncryptedSharedPreferences]
58
+ */
59
+ public const val SpotifyCurrentPkceCodeVerifierKey : String = " spotifyCurrentPkceCodeVerifier"
60
+
56
61
/* *
57
62
* The activity to return to if re-authentication is necessary on implicit authentication. Null except during authentication when using [guardValidImplicitSpotifyApi]
58
63
*/
@@ -101,6 +106,13 @@ public class SpotifyDefaultCredentialStore(
101
106
get() = encryptedPreferences.getString(SpotifyRefreshTokenKey , null )
102
107
set(value) = encryptedPreferences.edit().putString(SpotifyRefreshTokenKey , value).apply ()
103
108
109
+ /* *
110
+ * Get/set the current Spotify PKCE code verifier.
111
+ */
112
+ public var currentSpotifyPkceCodeVerifier: String?
113
+ get() = encryptedPreferences.getString(SpotifyCurrentPkceCodeVerifierKey , null )
114
+ set(value) = encryptedPreferences.edit().putString(SpotifyCurrentPkceCodeVerifierKey , value).apply ()
115
+
104
116
/* *
105
117
* Get/set the Spotify [Token] obtained from [spotifyToken].
106
118
* If the token has expired according to [spotifyTokenExpiresAt], this will return null.
Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ public abstract class AbstractSpotifyPkceLoginActivity : AppCompatActivity() {
92
92
// launch the activity when a Spotify intent result has been received
93
93
if (intent?.isSpotifyPkceAuthIntent(redirectUri) == false ) {
94
94
authorizationIntent = Intent (Intent .ACTION_VIEW , getAuthorizationUrl())
95
+ credentialStore.currentSpotifyPkceCodeVerifier = pkceCodeVerifier
95
96
startActivity(authorizationIntent)
96
97
finish()
97
98
}
@@ -150,7 +151,7 @@ public abstract class AbstractSpotifyPkceLoginActivity : AppCompatActivity() {
150
151
redirectUri = redirectUri,
151
152
authorization = SpotifyUserAuthorization (
152
153
authorizationCode = authorizationCode,
153
- pkceCodeVerifier = pkceCodeVerifier
154
+ pkceCodeVerifier = credentialStore.currentSpotifyPkceCodeVerifier
154
155
),
155
156
options ? : {}
156
157
).build()
You can’t perform that action at this time.
0 commit comments