I was wondering what the best practice to reauthenticate a user with OAuth2.0 is. Specifically for a desktop program that is using Spotify's Authorization Code with PKCE Flow. I'm pretty sure I need to store the Refresh Token to do so, I've already implemented this and it works perfectly. I am asking since I'm aware of the threats of someone gaining access to this Token according to RFC 6819.
Is it okay to simply encrypt and store the Refresh Token in a file? What encryption would be preferable? Or should I use a completely different value for reauthenticating the user?
Sorry if this is a very simple problem but I am new to OAuth2.0 and so far I've been unable to find something regarding desktop programs without databases.
TLDR;
First, refer to this document OAuth 2.0 Security Best Current Practice which is periodically updated instead of RFC6819 which hasn't been updated in a while.
A couple of general best practices:
Refresh tokens were designed as a way to NOT require the user to re-authenticate/authorize when retrieving a new access token. If you don't care about this, then don't use the refresh tokens and have the user re-authenticate/authorize when the access token is expired.
If you're talking specifically about using Spotify's API, then you don't have much control over what the authz server, aka Spotify, can do or the options provided. Spotify currently expires access tokens in 1 hr and always provides a refresh token in the response (although, you don't have to use it) and provides a new refresh token in the response when refreshing an access token.
Since Spotify provides a new refresh token with each refresh, you can periodically refresh to create your own "rolling" mechanism. That way if a refresh token leaked at some point, there's a shorter time frame when it can be used (your rolling duration). For example, every 15min., use the refresh token to retrieve a new access token AND new refresh token. *I am making an assumption that Spotify is revoking the older refresh token, but they don't explicitly mention that, so you may want to test if trying this out.