Skip to content

Commit 58743d0

Browse files
committed
fix: refresh token 5 minutes early
1 parent deeca48 commit 58743d0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Managers/AuthManager.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ public function loadAuthSession($authCredentials)
7575

7676
public function refreshTokenIfExpired()
7777
{
78-
if ($this->authCredentials->expiresIn->isPast()) {
78+
$expiresIn = $this->authCredentials->expiresIn->copy();
79+
80+
// if token is going to expire in next 5 minutes, refresh token 5 minutes early
81+
if ($expiresIn->subMinutes(5)->isPast()) {
7982
$this->refreshToken();
8083
}
8184
}

0 commit comments

Comments
 (0)