id"; $cachedToken = Cache::get($cacheKey); if ($cachedToken) { return $cachedToken; } if (! $account->username || ! $account->password || ! $account->instance_url) { throw new PlatformAuthException(PlatformEnum::LEMMY, 'Missing credentials for account: ' . $account->username); } $api = new LemmyApiService($account->instance_url); $token = $api->login($account->username, $account->password); if (!$token) { throw new PlatformAuthException(PlatformEnum::LEMMY, 'Login failed for account: ' . $account->username); } // Cache for 50 minutes (3000 seconds) to allow buffer before token expires Cache::put($cacheKey, $token, 3000); return $token; } }