diff --git a/lib/private/Files/ObjectStore/SwiftFactory.php b/lib/private/Files/ObjectStore/SwiftFactory.php
index caa4774daba8ec3d95706b16276364ae53761ecf..b817aac029937561e2d2656b6e856bd9b5a9c88c 100644
--- a/lib/private/Files/ObjectStore/SwiftFactory.php
+++ b/lib/private/Files/ObjectStore/SwiftFactory.php
@@ -56,7 +56,7 @@ class SwiftFactory {
 	private function getCachedToken(string $cacheKey) {
 		$cachedTokenString = $this->cache->get($cacheKey . '/token');
 		if ($cachedTokenString) {
-			return json_decode($cachedTokenString);
+			return json_decode($cachedTokenString, true);
 		} else {
 			return null;
 		}
@@ -131,9 +131,9 @@ class SwiftFactory {
 
 		$cachedToken = $this->params['cachedToken'];
 		$hasValidCachedToken = false;
-		if (is_array($cachedToken)) {
+		if (\is_array($cachedToken) && ($authService instanceof IdentityV3Service)) {
 			$token = $authService->generateTokenFromCache($cachedToken);
-			if (is_null($token->catalog)) {
+			if (\is_null($token->catalog)) {
 				$this->logger->warning('Invalid cached token for swift, no catalog set: ' . json_encode($cachedToken));
 			} else if ($token->hasExpired()) {
 				$this->logger->debug('Cached token for swift expired');