Gary Ginsberg’s proximity to power during his years as a lawyer in the Clinton White House gave him a keen understanding of how influence works in the executive branch.

But the spark for his new book, “First Friends: The Powerful, Unsung (and Unelected) People Who Shaped Our Presidents,” came from his observations of two other political figures: Gary Hart and Donald Trump.

Ginsberg, the former head of corporate communications for News Corp. and Time Warner, became fascinated by the notion of close friends who exert influence on presidents when he followed Hart’s boomerang effort to secure the Democratic nomination in 1988. It was no secret that Warren Beatty was a trusted adviser to the former senator from Colorado.

“I saw that Beatty was the one guy who could cut right through everything around the campaign and speak to Hart in the most blunt terms,” Ginsberg says.

Years later, as the Trump administration began, Ginsberg noted that the former “Apprentice” host didn’t seem to have the kind of close friendships that have been important to other occupants of the Oval Office. Ginsberg’s “First Friends” book proposal was snapped up by Hachette and became the labor of love that helped him get through the pandemic.

One of the biggest revelations in his research came from Caroline Kennedy, daughter of President John F. Kennedy. She identified David Ormsby-Gore, the onetime British ambassador to the U.S., as her father’s “first friend.”

“I would never have figured that out on my own, but a relationship that JFK forged in 1938 had a profound effect on his foreign policy,” Ginsberg says.