Reputation: 321
I don't know if there is a problem with my code but; using google-apis nodejs client for Drive REST API.
However, when I refresh my access token with the refresh token provided, it gives me an expiry time as seconds. (3600 more seconds from request)
I store them in a text file. Then I set credentials before a new request.
oauth2Client.setCredentials({
access_token: gTokens[0],
refresh_token: gTokens[1],
expiry_date: gTokens[2]
});
var expiryDate = oauth2Client.credentials.expiry_date;
var isTokenExpired = expiryDate ? expiryDate <= (new Date()).getTime() : false;
Then I check wheter access token is expired or not. The code above gives me true for isTokenExpired. Even If my access token is expired, I can upload a file to Google Drive with an access token which is expired long time ago.
What's the problem?
Upvotes: 0
Views: 1443
Reputation: 50701
There is no problem - you're also saving the refresh_token
, it sounds like, and the client library has logic that uses the refresh_token
to get a new access_token
if the first one you use fails.
What it does not do, however, is save this token automatically. You need to take action to setup hooks to do the save if necessary.
Upvotes: 3