adamint/Spotify-Api-Test-App

The PKCE token is never refreshed

yannallain opened this issue · 1 comments

Issue:
When the token is expired, it is never refreshed and the user needs to authenticate again.

Description:
In VerifyLoggedInUtils, when the token is expired, the Model.credentialStore.spotifyToken is null and an ReAuthenticationNeededException is thrown.
In the catch clause the variable usesPkceAuth is always false since the following condition is used:
val usesPkceAuth = Model.credentialStore.spotifyToken?.refreshToken != null
but the Model.credentialStore.spotifyToken is null since it's already expired.

Possible Fix:
Instead of:
val usesPkceAuth = Model.credentialStore.spotifyToken?.refreshToken != null
Replace with:
val usesPkceAuth = Model.credentialStore.spotifyRefreshToken != null

Thank you! This will be fixed in the upcoming commit.