xxxxxxxxxx
The Google Auth server issued Refresh tokens never expire —
that's the whole point of the refresh tokens. The refresh token
will expire (or I should say become unauthorized) when the user
revokes access to your application.
Refer this doc it clearly states the function of refresh tokens.
xxxxxxxxxx
// Send an POST request to: https://oauth2.googleapis.com/token
// send data in form of an encoded url (x-www-form-urlencoded):
// client_id: CLIENT_ID,
// client_secret: CLIENT_SECRET,
// refresh_token: refreshToken,
// grant_type: "refresh_token"
// node js + axios example:
import axios from "axios"
const params = {
client_id: <YOUR_CLIENT_ID>
client_secret: <YOUR_CLIENT_SECRET>
refresh_token: <REFRESH_TOKEN_FOR_THE_USER>
grant_type: "refresh_token"
}
// URLSearchParams turns JSON into encoded url string
await axios.post("https://oauth2.googleapis.com/token", new URLSearchParams(params))
.then((response) => {
console.log(response)
})