The flight in the Cessna 172 lasted around 64 days with two pilots switching to fly the plane. To my knowledge both FAA and EASA have rest periods which pilots have to follow. Also the refueling was done by a truck matching the speed and handing over a hose to refuel. How was this flight legal regarding rest periods and refueling maneuver?
Regarding flight time, duty periods, or rest requirements, no current regulations would have specifically imposed limitations on this flight. This flight would have been operated as a private flight under 14 CFR 91 under today's regulations.
The flight, duty, and rest requirements are specified only for certain commercial operations including airline, charter, and fractional. Flight instruction is also generally limited to 8 hrs in a 24 hr period. Paid pilots routinely fly 12-14+ hours in a day, including in certain patrol activities and in flying private jets.
Refueling is not generally restricted by FAA aiation regulations in a way that would specifically impact this operation. As with the flight time concern, the catch all "careless and reckless" regulation might apply first.
For some of the same reasons that the crew flight time was not restricted, many of the maintenance requirements such as 100 hr inspections, would not be required of a private flight. However, the 100 hr seat rail inspection AD would be problematic today.
As noted in the comments Crew Rest Periods are only applicable to commercial flights operating under part 121, 135 and 91K as per the FAA's regulation, specifically 14 CFR § 121.471. But it does not apply for flights strictly operating under part 91 which they likely were.
You can make a case that they could have potentially been in violation of
(a) Aircraft operations for the purpose of air navigation. No person may operate an aircraft in a careless or reckless manner so as to endanger the life or property of another.
but that is the FAA's catch all and somewhat broadly applicable when they see fit. There have been various endurance records set over the years (all legally) and in all cases precautions were taken to ensure that the flight was safe. Generally this involves two pilots taking shifts however the recent Solar Impulse flight set the solo record.
As for the refueling, there is no regulation that an aircraft must be on the ground, or stopped in order to re-fuel, the military refuels mid air quite often.