I'm using v3 of the youtube data api for my server.So far I'm able to create a token by getting a code from the redirect.
oauth2Client.getToken(req.query.code, function(err, token) { if (err) { console.log('Error while trying to retrieve access token', err); return; } oauth2Client.credentials = token; storeToken(token); res.redirect("/channel"); });I'm storing this token locally, but I have a couple questions on the following;
- How do I check if this token is valid when a request is about to be made?
- How do I get a new token by using the refresh token if the token I currently have is expired?