From 3039ddc2ecd27d2fb9f4d1721e0be8214178d76f Mon Sep 17 00:00:00 2001 From: LukasRos Date: Mon, 11 Nov 2024 00:04:20 +0100 Subject: [PATCH] Added expiry logging and fixed token caching --- CloudObjects/SDK/WebAPI/OAuth2AuthServer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CloudObjects/SDK/WebAPI/OAuth2AuthServer.php b/CloudObjects/SDK/WebAPI/OAuth2AuthServer.php index e7557c1..fb656d0 100644 --- a/CloudObjects/SDK/WebAPI/OAuth2AuthServer.php +++ b/CloudObjects/SDK/WebAPI/OAuth2AuthServer.php @@ -120,7 +120,7 @@ class OAuth2AuthServer { $grantCacheKey = sha1(json_encode($params)); $ts = microtime(true); - $tokenResponse = json_decode($this->cacheAndLog->getFromCacheCustom($grantCacheKey)); + $tokenResponse = json_decode($this->cacheAndLog->getFromCacheCustom($grantCacheKey), true); if (isset($tokenResponse)) { $this->cacheAndLog->logInfoWithTime("Reused access token for <".$this->authServer->getId()."> from cache.", $ts); @@ -134,7 +134,7 @@ class OAuth2AuthServer { $expiry = isset($tokenResponse['expires_in']) ? $tokenResponse['expires_in'] : 84600; - $this->cacheAndLog->logInfoWithTime("Retrieved access token for <".$this->authServer->getId()."> from token endpoint.", $ts); + $this->cacheAndLog->logInfoWithTime("Retrieved access token for <".$this->authServer->getId()."> from token endpoint and will cache for ".$expiry." seconds.", $ts); $this->cacheAndLog->putIntoCacheCustom($grantCacheKey, json_encode($tokenResponse), $expiry); }