2
我想問一下谷歌的令牌對象返回期限和我們在憑證中設置的區別?令牌過期日期(Google OAuth2)和憑證之間有什麼區別?
oauth2Client.getToken(code, function (err, tokens) {
// Now tokens contains an access_token and an optional refresh_token. Save them.
if (!err) {
oauth2Client.setCredentials(tokens);
}
});
// Retrieve tokens via token exchange explained above or set them:
oauth2Client.setCredentials({
access_token: 'ACCESS TOKEN HERE',
refresh_token: 'REFRESH TOKEN HERE'
// Optional, provide an expiry_date (milliseconds since the Unix Epoch)
// expiry_date: (new Date()).getTime() + (1000 * 60 * 60 * 24 * 7)
});
你錯了,我在setCredentials中設置了過期日期10秒,10秒後令牌不起作用。 –
這可能是你的NodeJs庫中的東西。您正在使用的通用oauth2Client不是專門爲Google設計的。圖書館將不會過期。如果您使用訪問令牌並在沒有使用庫的情況下使用它,它仍然可以工作。除非有人認爲向我懷疑的圖書館添加撤銷。 – DaImTo
是的,它在圖書館https://github.com/google/google-api-nodejs-client/issues/261如果你設置爲低,它會過期。 – DaImTo