I started using this tutorial to create a application sample, that uses refresh tokens. But in the application, the user have to click in a button to access the token and refresh it with a new token. I wish my application automatically request a new refresh token before it expires. How I can do this?
You should typically keep track of the time the token will expire and then request the new token before the expiration occurs. Requesting early in OAuth2.0 is acceptable.