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(
5353 */
5454 public const val SpotifyRefreshTokenKey : String = " spotifyRefreshToken"
5555
56+ /* *
57+ * The PKCE code verifier key currently being used in [EncryptedSharedPreferences]
58+ */
59+ public const val SpotifyCurrentPkceCodeVerifierKey : String = " spotifyCurrentPkceCodeVerifier"
60+
5661 /* *
5762 * The activity to return to if re-authentication is necessary on implicit authentication. Null except during authentication when using [guardValidImplicitSpotifyApi]
5863 */
@@ -101,6 +106,13 @@ public class SpotifyDefaultCredentialStore(
101106 get() = encryptedPreferences.getString(SpotifyRefreshTokenKey , null )
102107 set(value) = encryptedPreferences.edit().putString(SpotifyRefreshTokenKey , value).apply ()
103108
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+
104116 /* *
105117 * Get/set the Spotify [Token] obtained from [spotifyToken].
106118 * 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() {
9292 // launch the activity when a Spotify intent result has been received
9393 if (intent?.isSpotifyPkceAuthIntent(redirectUri) == false ) {
9494 authorizationIntent = Intent (Intent .ACTION_VIEW , getAuthorizationUrl())
95+ credentialStore.currentSpotifyPkceCodeVerifier = pkceCodeVerifier
9596 startActivity(authorizationIntent)
9697 finish()
9798 }
@@ -150,7 +151,7 @@ public abstract class AbstractSpotifyPkceLoginActivity : AppCompatActivity() {
150151 redirectUri = redirectUri,
151152 authorization = SpotifyUserAuthorization (
152153 authorizationCode = authorizationCode,
153- pkceCodeVerifier = pkceCodeVerifier
154+ pkceCodeVerifier = credentialStore.currentSpotifyPkceCodeVerifier
154155 ),
155156 options ? : {}
156157 ).build()
You can’t perform that action at this time.
0 commit comments