Skip to content

Commit 4aedefc

Browse files
authored
Update Iam.php
1 parent 246d894 commit 4aedefc

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/Iam.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -354,18 +354,14 @@ protected function loadToken()
354354
{
355355
if ($this->iam_token)
356356
{
357-
if ($this->refresh_at < microtime(true)){
357+
if ($this->refresh_at < time()){
358358
try {
359359
return $this->newToken();
360360
} catch (\Exception $e){
361361
return $this->iam_token;
362362
}
363363
}
364-
else if ($this->expires_at > time())
365-
{
366-
return $this->iam_token;
367-
}
368-
return $this->newToken();
364+
return $this->iam_token;
369365
}
370366

371367
return $this->loadTokenFromFile();
@@ -386,7 +382,7 @@ protected function loadTokenFromFile()
386382
{
387383
$this->iam_token = $token->iamToken;
388384
$this->expires_at = $token->expiresAt;
389-
$this->refresh_at = $token->refreshAt ?? $token->expiresAt;
385+
$this->refresh_at = $token->refreshAt ?? time();
390386
$this->logger()->info('YDB: Reused IAM token [...' . substr($this->iam_token, -6) . '].');
391387
return $token->iamToken;
392388
}

0 commit comments

Comments
 (0)