Skip to content

Commit 8e3fa05

Browse files
committed
Ensure access tokens are stored in cache for the correct access token exp time
1 parent 5244296 commit 8e3fa05

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/Bookboon/ApiBundle/Service/ApiFactory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ public static function credentialFactory(Bookboon $bookboon, Cache $cache, Confi
4444

4545
if ($token === false) {
4646
$token = $bookboon->getClient()->requestAccessToken([], OauthGrants::CLIENT_CREDENTIALS);
47-
$cache->save("bookboonapi.{$config->getId()}", $token);
47+
48+
$ttl = $token->getExpires() - time();
49+
$cache->save("bookboonapi.{$config->getId()}", $token, $ttl);
4850
}
4951

5052
return $token;

0 commit comments

Comments
 (0)