Skip to content

Commit a740333

Browse files
authored
Update Iam.php
1 parent 5359d7c commit a740333

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Iam.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,14 @@ protected function saveToken($token)
403403
$this->expires_at = $this->convertExpiresAt($token->expiresAt ?? '');
404404
$this->refresh_at = $token->refreshAt;
405405

406-
file_put_contents($tokenFile, json_encode([
406+
$randPath = $tokenFile."-tmp".bin2hex(random_bytes(10));
407+
file_put_contents($randPath, json_encode([
407408
'iamToken' => $this->iam_token,
408409
'expiresAt' => $this->expires_at,
409410
'refreshAt' => $this->refresh_at
410411
]));
412+
rename($randPath, $tokenFile);
413+
411414
}
412415

413416
/**

0 commit comments

Comments
 (0)