When Rolling Stone was preparing to move its offices from San Francisco to New York in 1977, co-founder and editor-in-chief Jann Wenner asked one of his advertising salespeople for a simple favor: retrieve a package from the magazine’s hometown airport and deliver it to him in his new city.

But when the woman met up with Jann in Manhattan, he opened the parcel to reveal cocaine — which he then snorted right in front of her.

“I could have been arrested,” recalled the horrified employee, who quit soon after. “I could be in jail.”

Founded 50 years ago, Rolling Stone was a self-proclaimed beacon of radical counterculture.

But as revealed in “Sticky Fingers” (Knopf, out Tuesday) — a new biography of Jann, written by Joe Hagan — many of the magazine’s staffers didn’t just chronicle sex, drugs and rock ’n’ roll. They lived it, hardcore.

According to the book, employees even dealt drugs at the office. Among the biggest partiers were Jann, who snorted coke and downed vodka at the office, and staff photographer Annie Leibovitz — who, Hagan writes, slept with many of her famous subjects and, perhaps, even Jann and his then-wife, Jane.

“Sticky Fingers” is the product of four years’ work for Hagan. Jann, now 71, participated fully, offering unprecedented access to his archives and clocking around 100 hours of interviews.

At first, Jann expressed his desire to avoid hagiography. “One of the things that he said at the outset was that he didn’t want to have a book that was like Clive Davis’ memoir [2013’s ‘The Soundtrack of My Life’] because that was like a vanity book,” Hagan told The Post.

Jann gave the writer free rein to interview his friends, family and colleagues — some 250 of them. But after reading the completed book in September, he went cold on Hagan. The two are no longer on speaking terms.

“I gave Joe time and access in the hope he would write a nuanced portrait about my life and the culture Rolling Stone chronicled,” said Jann in a statement given to the New York Times this week. “Instead, he produced something deeply flawed and tawdry.”

Hagan described Jann’s reaction as “painful,” but stands by his work. “I’m not angry, I just don’t agree with him,” he said. “I hope that in time, he will come to understand that the book places him at the center of the times he lived in.”

It’s certainly not the first time Jann has changed his stripes. As covered in the book, he was known to befriend musicians such as Bob Dylan, John Lennon and members of the Rolling Stones, and then publish less-than-flattering portrayals of them in his magazine.

As Art Garfunkel told Hagan: “If he puts his arm around your back, there might be a dagger there.”

Jann and then-wife Jane had an apartment on East 66th Street in which was installed a piece of furniture suited to the high-flying lifestyle, Hagan writes. Designer Dakota Jackson, whose family was in the magic business, created a $15,000 entertainment console with secret cocaine compartments. The unit contained a pull-out mirror — the perfect surface for snorting the drugs.

Despite the hiding spots, the drug use at the Wenners’ home was anything but private. “[Jann] was a natural social climber. He was attracted to high society and money and fame,” Hagan said.

The couple’s pad became a clubhouse for partying celebrities: Mikhail Baryshnikov, John Belushi, film director Milos Forman and Rolling Stone writer — and notorious drug fiend — Hunter S. Thompson. Richard Gere reportedly once passed out on the sofa after consuming a marijuana brownie.

Though he was running a high-profile business, Jann’s days weren’t that different from his wild nights. At the magazine’s Fifth Avenue headquarters, two photo department employees were dealing cocaine out of a darkroom. As Hagan writes, “[Jann] was the biggest customer of all, but he also used grams of cocaine as bonuses for employees who pleased him.”

Karen Mullarkey, then a photo editor at the magazine, recalled to Hagan how she would be rewarded for getting celebrated staff photographer Leibovitz — who progressed from recreational user to full-blown addict over the course of the ’70s — through a deadline. “I would come in and find . . . one of those little folding envelopes of coke, [left] on my light box . . . a gift from Jann.”

During parties, the staff would snap a photo of everyone who came by the darkroom to do a line. “They had a whole hall with like 400 or 500 Polaroids,” Jann told Hagan.

The editor could often be found drinking vodka from the bottle — it helped take the edge off the cocaine. Hagan writes that if Jann “heard an office door slam, his Pavlovian response was to go find out who was doing cocaine without him.”

At home, Jann’s marriage to Jane was suffering. According to the book, the two were having affairs — Jann with both men and women. When they separated for a while, he had a romance with Caroline Kennedy in 1978; Caroline’s mother, Jacqueline Onassis, reportedly did not approve and banned Jann from her social circles for a couple of years.

A Rolling Stone business staffer recalled to Hagan showing up to the Wenners’ Hamptons home for an afternoon meeting one weekend and seeing Jann, Jane and Leibovitz all leaving the bedroom together, with drugs in plain sight behind them.

“We all conjectured that there were a lot of threesomes,” said Claeys Bahrenburg, then the magazine’s advertising director.

(Jane could not be reached for comment. Leibovitz did not respond by deadline.)

It would not have been, the book claims, the first time Leibovitz had found herself in the bed of a collaborator. Former art director Roger Black recalls how her contact sheets — prints showing all the negatives from a photo shoot — would often reveal the lenser in bed with male and female subjects.

“If she could talk them into bed, they were in bed,” Black told Hagan. “Sometime it’d just be super intimate; sometimes there would be sex.”

Said Leibovitz to Hagan: “If you had Mick Jagger coming on to you or something, you just . . . whatever.”

Although she insists she always had the pursuit of the photograph as her first priority, Leibovitz’s activities were a running joke at the office. While a potential interview with Fidel Castro was being discussed, staff quipped that the photographer would probably end up sleeping with the Cuban dictator.

‘If you had Mick Jagger coming on to you or something, you just . . . whatever.’ - Annie Leibovitz

When it came to the rock ’n’ roll lifestyle, Leibovitz could give the most seasoned musicians a run for their money. In 1975, she accompanied the Rolling Stones on tour — against the advice of Jann, who knew the group was heavily into hard drugs at the time. But when Hagan asked Keith Richards, a full-blown heroin addict at the time, if he’d shown Leibovitz some “tricks,” Richards replied, “Possibly, she’s got a good eye for tricks.”

On one occasion, the author writes, Jann got a call from a member of the Eagles in the middle of the night, complaining that Leibovitz had used up all his crystal meth. He replied, “So what do you want me to do about it?”

At the time, Hagan writes, “Leibovitz said she didn’t know she was gay, nor did she think of Wenner as gay. Sex, like drugs, was just another opportunity.” Eventually, Jann would leave Jane for model Matt Nye and come out as gay in 1995. Leibovitz would go on to parent three kids with writer Susan Sontag.

Hagan said the relationships among Jann, Jane, Leibovitz and the rest of the staff at Rolling Stone were “like soap operas . . . more dramatic than ‘Mad Men.’ ”

Jann’s business ambitions were huge, but his decisions could be questionable. In 1976, while under the influence of cocaine, he made a last-minute cover photo swap at a cost of $15,000. Jann also continued to write fawning reviews of his favorite artists, especially Bob Dylan. In 1979, the singer documented his conversion to Christianity in the middling-at-best “Slow Train Coming,” which Jann declared “one of the finest albums Dylan has ever made.” The staff tried to stop the review from going to print, but Jann overruled them.

An attempt to revive the photo magazine Look in 1979 foundered after just two issues, and Jann’s expansion into Hollywood and TV also came up short. The Rolling Stone 10th-anniversary television special that aired on CBS in 1977 featured a 20-minute Broadway-style medley of Beatles songs with dancing strawberries, and an actor in a Richard Nixon mask singing “I’m a Loser.”

“Rolling Stone’s co-founder Ralph Gleason [who died in 1975] once said that the proof of [the magazine] being a good idea was that it survived Jann Wenner’s mismanagement,” said Hagan.

As the 1970s turned into the ’80s, Jann took Rolling Stone in a more mainstream direction. Slowly but surely, Jann left part of his old self behind, too. His primary vice became vodka; but after he was diagnosed as diabetic in 1986, he cut back on that, too.

“Jann forged through it, and he had a willpower that allowed him to say, ‘I’m gonna change now.’ That was impressive,” said Hagan.

Rolling Stone turns 50 in November, and it faces an uncertain future. Jann has put his 49 percent share of the business up for sale (the other 51 percent was bought by a digital music company based in Singapore). The editor-in-chief is also recovering from a triple bypass operation he had over the summer.

“I think it’s probably hard for Jann right now, because maybe things haven’t turned out the way he’d hoped,” said Hagan. “But the mistakes and controversies of his life were the mistakes and controversies of a generation.”