In the browser, I'm doing:
let { code } = await this.auth2.grantOfflineAccess();
I then save that code
in my DB.
Then on the server (node.js), I'm doing:
const { tokens } = await oauth2Client.getToken(code)
oauth2Client.setCredentials(tokens)
let { data } = await googleCalendar.calendarList.list({
auth: oauth2Client
})
The first time, tokens
has a refresh_token
. I save that as well. When I run this once, it works fine. When I run it again, it says the token is invalid. Somehow, I have to use the refresh_token
, to get a new token, but I don't know how. Can someone please explain like I'm 5?
Thanks