Skip to content

Commit 1f81e41

Browse files
committed
add clock slew compensation
1 parent f97ce6c commit 1f81e41

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/oauth.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ impl OAuthClient {
338338
self._access_token.read().unwrap().clone()
339339
};
340340
if let Some(access_token) = cached_token {
341-
if access_token.expires_at > now {
341+
if access_token.expires_at > (now + chrono::Duration::seconds(60)) {
342342
return Ok(access_token.access_token);
343343
} else if let Some(refresh_expires_at) = access_token.refresh_expires_at {
344344
if let Some(refresh_token) = access_token.refresh_token {
@@ -462,7 +462,7 @@ impl OAuthClient {
462462

463463
let token = match alcoholic_jwt::validate(token, key, validations) {
464464
Ok(k) => k,
465-
Err(e) => {
465+
Err(_) => {
466466
return Err(VerifyTokenError::Forbidden)
467467
}
468468
};
@@ -496,7 +496,7 @@ impl OAuthClient {
496496
let now = Utc::now();
497497

498498
let access_token = {
499-
if token.expires_at > now {
499+
if token.expires_at > (now + chrono::Duration::seconds(60)) {
500500
token
501501
} else if let Some(refresh_expires_at) = token.refresh_expires_at {
502502
if let Some(refresh_token) = &token.refresh_token {

0 commit comments

Comments
 (0)