Former President Barack Obama said that former House Speaker John Boehner and the late Sen. John McCain, R-Ariz., would "badmouth" their fellow Republicans to him "in private."

"[Boehner] and I had a perfectly good relationship, but he had to act a certain way for his caucus. He would badmouth many of them to me, in private. Much as John McCain did. The issue was never personal — Mitch McConnell is not buddy-buddy with anyone," Obama told The Atlantic in an interview ahead of the release of his presidential memoir's first volume.

OBAMA SAYS THERE IS 'NO LEGAL BASIS' FOR TRUMP ELECTION CHALLENGES

Obama defended himself in the interview, saying a lack of bipartisan agreement during his presidency was not for his lack of trying.

Former President Barack Obama speaks at a rally as he campaigns for Democratic presidential candidate former Vice President Joe Biden, Monday, Nov. 2, 2020, at Turner Field in Atlanta. (AP Photo/Brynn Anderson)

Former President Barack Obama speaks at a rally as he campaigns for Democratic presidential candidate former Vice President Joe Biden, Monday, Nov. 2, 2020, at Turner Field in Atlanta. (AP Photo/Brynn Anderson)

"The issue with Republicans is not that I didn’t court them enough," he said. "We would invite them to everything: movie nights, state dinners, Camp David, you name it. The issue was not a lack of schmoozing. The issue was that they found it politically advantageous to demonize me and the Democratic Party."

President Trump has infamously criticized McCain for voting against repealing the Affordable Care Act, which Obama has touted as one of his greatest accomplishments. 

Obama defended his recent attacks on Trump amid his return to politics in a CBS interview released on Sunday.

OBAMA, IN NEW INTERVIEW CLIP, SAYS GOP ON 'DANGEROUS PATH' IN 'GOING ALONG WITH' TRUMP ELECTION CLAIMS

While Obama remained largely off the radar during Trump's term in office, he stepped back into the spotlight during the 2020 election cycle to stump for Democratic President-elect Joe Biden, his former vice president. This caused some to question whether it breaks norms for a former president to campaign against a sitting commander in chief.

"It is not my preference to be out there," Obama said. "I think we were in a circumstance in this election in which certain norms, certain institutional values that are so extraordinarily important, had been breached that it was important for me as somebody who had served in that office, to simply let people know this is not normal."

CLICK HERE FOR THE FOX NEWS APP

Obama has a 768-page memoir -- "A Promised Land" -- arriving in bookstores around the world this week. 

Fox News' Julia Musto contributed to this report.