An early effort from Andre Gray and a double from Alex Pritchard gave Mark Warburton’s Bees their third pre-season win from three, whilst the feisty French side responded with goals from Neal Maupay Lloyd Palun, keeping the pressure on until the end.
All five goals came in the first half and scoring began after just 70 seconds as Gray headed in through a gap in the Nice defence.
The visitors retaliated in three minutes with Maupay finishing after being teed up by team-mate Lucas Rougeaux.
Pritchard stepped up to curl a free-kick home from 20 yards and an Odubajo assist set up Pritchard’s second, before Nice battled back again with a shot from Palun.
Seconds after the break Palun almost levelled it spectacularly, but was ruled offside and the remainder of the game passed without incident.
Bees boss Warburton said the game had been a “really good test” for his side and that there were many positives to take away.
“We learned a lot, there were many positives,” he told the club’s official website.
“They were a good side and I hope we surprised them with our quality, certainly in the first 70 minutes.
“They showed us how well they moved the ball, the quality was outstanding.
“They punished us when we were sloppy and in the last 15 minutes we saw if you give the ball away you pay the price.
“It was an interesting challenge, I am pleased it went well and I think the players benefited enormously.”
Brentford will face CA Osasuna on Tuesday and Warburton hopes to give more pitch time to younger and newer players then, before a London derby with Crystal Palace.
“The idea was to maximise the training camp, get the fitness levels to where we wanted them to be, and we saw that at Barnet,” he explained.
“They got pitch time. That is tremendous for us.
“More will do so on Tuesday and hopefully on Thursday we will start with the squad in sync and ready for a very tough test against Crystal Palace on Saturday.”
Brentford begin their Championship campaign on August 9 against Charlton Athletic.