xdevplatform/twitter-api-typescript-sdk

isAccessTokenExpired always returns true

PMLyf opened this issue · 0 comments

PMLyf commented

One line summary of the issue here.
When checking the new access token provided by requestAccessToken, isAccessTokenExpired always returns true

Expected behavior

Token should not be expired
As concisely as possible, describe the expected behavior.
requestAccessToken returns a new token with expiry time. Local checks pass for the expiry time should also pass with api call

Actual behavior

always returns true
As concisely as possible, describe the observed behavior.

Steps to reproduce the behavior

generate auth link
in call back request a new access token
check if the token is expired

Please list all relevant steps to reproduce the observed behavior.

const clientT = new auth.OAuth2User({
client_id: process.env.TWITTER_CLIENT_ID as string,
client_secret: process.env.TWITTER_CLIENT_SECRET as string,
callback: process.env.TWITTER_OAUTH_CALLBACK_URL as string,
scopes: ["tweet.read", "tweet.write", "users.read", "offline.access"],
token: {
refresh_token: refreshToken,
token_type: "refresh_token",
},
});

const isExpired = clientT.isAccessTokenExpired();
if (isExpired.valueOf()) {
logger.log("Token is expired");
const newToken = await clientT.refreshAccessToken();
logger.log("New Token: " + JSON.stringify(newToken));
}