getMalTokenExpiry computes the absolute expiry time of a MalTokenResponse.
It adds expires_in from the response returned by getMalAccessToken or refreshMalAccessToken to the supplied clock value, so callers can schedule refresh before the token held in MalCredentials expires.
expires_in
MalCredentials
The MalTokenResponse whose expires_in to evaluate.
The current time in milliseconds since the Unix epoch.
The moment the access token expires.
const expiresAt = getMalTokenExpiry(token);if (expiresAt.getTime() - Date.now() < 60_000) await refreshMalAccessToken({ clientId, refreshToken }); Copy
const expiresAt = getMalTokenExpiry(token);if (expiresAt.getTime() - Date.now() < 60_000) await refreshMalAccessToken({ clientId, refreshToken });
https://myanimelist.net/apiconfig/references/authorization
getMalTokenExpiry computes the absolute expiry time of a MalTokenResponse.
It adds
expires_infrom the response returned by getMalAccessToken or refreshMalAccessToken to the supplied clock value, so callers can schedule refresh before the token held inMalCredentialsexpires.