To determine when to use a refresh token to ask for a new access token, I'm aware of two approaches (below). Are either of these approaches possible without modifying the passport-google-oauth library?
1) The "pre-emptive" method
- Save the access token's expiry time when its granted
- Check the expiry time against the current time whenever using an access token to access the API
- If the access token is not expired, use it to access the API
- If the access token is expired (or close to being expired), supply the refresh token to get a new access token
2) The "handle failure" method
- Always supply access token
- If the access token fails to authenticate, supply the refresh token, get a new access token
Thanks. Also welcome any alternatives.