In the context of OAuth 2, how does one deal with refresh_token
expiry, or lack thereof?
I'm using JSON Web Tokens (JWTs) as access_token
s with a short lifetime (expires after 20 minutes). From what I understand, this means I shouldn't have to store the access_token
, only validate it (and consume the trusted information inside, like scopes).
However, I'm wondering how one implements refresh_token
s. In my research, I've seen that Google and others have refresh_token
s which are good forever, unless they are revoked, for any number of reasons. I assume this means the system must store all refresh tokens ever issued, so they can be marked as revoked.
Is this a problem when it comes to the storage of the tokens? It seems like you have a potentially infinite set of tokens which need to be stored and accessible forever.
Am I missing something? Are there best practices for implementing refresh tokens? Should they be (or NOT be) JWTs? Should the access_tokens also be stored, even when using JWTs? If so, is there any reason to keep them past their expiry time? What about JWT secrets changing over time?