I have read the PODIO documentation. I have in particular contemplated the following statement concerning use of the refresh_token
:
This request returns the same data as above, and you can continue to do this over and over again, to keep your application authenticated without having to ask the user to re-authenticate.
Does this mean that the refresh_token
will be indefinitely valid or does it expire:
- X days after being issued; or
- X days after the last use of it for obtaining a new
access_token
EDIT: Please see this PODIO Thread which asks the same questions but does not seem to give any conclusive answers about the PODIO implementation of the Oauth2.0 protocol.
The answer of your question:
...can be concluded from the section 1.5 and section 10.4 of the OAuth 2.0 specification.
Section 1.5 Introduction of refresh_token states:
section 10.4 Security Considerations for refresh_token states:
It can be concluded that if the authorization_server is able to verify the binding between a
refresh_token
and the client to whom it was issued thenrefresh_token
can be used to obtain multipleaccess_token
and will never expire. else the authorization sever will invalidate the oldrefresh_token
and generate newrefresh_token
with every access token refresh response.Refresh tokens will expire X days (or hours) after their creation. Depending on your security requirements this expiration will be 1 month or 1 hour.
You have to make the decision taking care some aspects as functionality and security.
TL; DR
Refresh token will eventually expire or become invalid and you should be ready for it.
Two scenarios:
User facing service (e.g.: authorization grant flow) - maybe ok to ignore the problem, because people are good in turning it off and on again, a.k.a refresh the page :-)
Server side long running service (e.g.: client credentials flow) - you should be ready for the situation when neither of access or refresh token works and re-initiate the authentication from scratch.
Real life
Refresh tokens may or may not have expiry time, depending on your provider they expire never, not as long as they're recently used, in months or in hours. Relying on the fact that you will receive new refresh token with refreshed access token may be tricky.
Timeout is not the only way in which token may become invalid. Consider following scenarios described in oauth0:
To add to that the tokens (access, refresh) can be stored in non-persistent storage in authentication provider service so if the service is restarted (crash, update) your tokens may be gone.
Conclusion
If you are writing long-running service which needs to be reliable don't rely on being able to refresh granted authentication forever through refresh tokens.