platform->label(); try { $response = $request(); } catch (ConnectionException $e) { throw new PlatformUnavailableException("{$name} API unreachable: {$e->getMessage()}"); } if ($response->serverError() || $response->status() === 429) { throw new PlatformUnavailableException( "{$name} API returned {$response->status()} during token refresh", $response->status(), ); } if ($response->failed()) { Log::error("TokenRefreshClient: {$name} token refresh failed", [ 'body' => TokenRedactor::redact($response->body()), ]); $body = $response->json(); $message = data_get($body, 'error_description') ?? data_get($body, 'error.message') ?? "Failed to refresh {$name} token"; throw new TokenExpiredException($message, platformErrorCode: (string) $response->status()); } return $response; } }