Skip to content

Commit 680f83b

Browse files
authored
Merge pull request #6 from bookboon/feature/storeAccessTokensAtSameTimeAsAccessTokenExpDate
Ensure access tokens are stored in cache for the correct access token…
2 parents 5244296 + 8e3fa05 commit 680f83b

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)