I've implemented the code to get access_token, refresh_token and expire_date. All these values are stored in the database already.
Now I need a way to get another access_token in case the old one is expired without using google-api-nodejs-client package
The reason is this module recently has bug, you can check it here (my comment is the latest) https://github.com/google/google-api-nodejs-client/issues/869#issuecomment-352401977 https://github.com/google/google-api-nodejs-client/issues/894.
At the moment, I tried something like this
GoogleTokens.findOne({isObsolete: false}).then((token) => {
let subscriptionsGetUrl = "https://www.googleapis.com/androidpublisher/v2/applications/" + req.query.packageName + "/purchases/subscriptions/" + req.query.subscriptionId + "/tokens/" + req.query.token + "?access_token=" + token.accessToken;
request(subscriptionsGetUrl, function (error, response, body) {
if (error) {
throw error;
}
res.success(JSON.parse(body).expiryTimeMillis);
});
});
But it will fail when access_token is expired.
Thanks.