audio-band icon indicating copy to clipboard operation
audio-band copied to clipboard

Change auth/refresh logic of spotify tokens

Open kodbulten opened this issue 3 years ago • 0 comments

Fixes #241

Removed infinite loop when a refreshToken has expired or been revoked. If token has been revoked we will now discard the token and Spotify will be deactivated as an audiosource and a message about the revoked token will display in the log. We will also never try and refresh an AccessToken with an Empty RefreshToken anymore, since that would never work anyway.

Added retries if Refreshing the access token fails for any other reason. If we reach maximum retries the RefreshToken will be considered bad and we will discard it, user will have to go through the Authorization process again.

Added retries for polling fails. If internet connection goes out for example, we will retry 20 times with increasing time between tries. What happened before was that the log was spammed every second with big error messages. If we reach maximum retries Spotify audosource will be disabled until reload.

Summary

Checklist

  • [x ] Tests passed
  • [ x] Changes validated (manually or automated)
  • [#241 ] Closes / Fixes #xxx (if applicable)

Additional details / comments

Authorize should really only be needed once. The RefreshToken should have a long lifetime (forever?) if it's not revoked. So even better would be to introduce a "connect" button for Spotify in the settings where all authorization is done. Then we would just use refreshing during normal operations, but some sort of message would need to be displayed if/when the refreshtoken becomes invalid/revoked. But this should work for now.

Manual test steps (if applicable)

kodbulten avatar Mar 16 '21 13:03 kodbulten