Thanks for this great post. I implemented it in my application. I have one operation that invalidates the access_token on the server side. I'm trying around with renewing it using the refresh_token, however not really successful for now. Do you have an idea how to implement a check, if the access_token is still valid and if not to refresh it using the refresh_token?
Thanks for this great post. I implemented it in my application. I have one operation that invalidates the access_token on the server side. I'm trying around with renewing it using the refresh_token, however not really successful for now. Do you have an idea how to implement a check, if the access_token is still valid and if not to refresh it using the refresh_token?
Thank you!
You can see the
~/plugins/auth.jsfile and functiondecodeTokenin it.So if token is still valid then you can do like
if (decodeToken(token).exp > 0)// valid
Basically this piece of code in the plugin does exactly that(also found in
~/plugins/auth.jsfile):if (refreshInterval < 0) {refreshInterval = (await refreshTokenF($auth, $axios, token, refreshToken) * 1000 - Date.now()) * 0.75
$auth.fetchUserOnce()
}