Some diehards in the Alberta oilpatch won't give credit to Liberal Prime Minister Justin Trudeau and Alberta NDP premier Rachel Notley for giving them the top gift on their Christmas wish list — approval of a new oil export pipeline. But according to a new book, those unlikely oilpatch allies did what former Prime Minister Stephen Harper wouldn't do to get Keystone XL constructed.

With a Donald Trump victory south of the border, Keystone XL may still be built one day, however its lengthy delays and rejection by Barack Obama have already cost millions, if not billions, in lost revenues for Canadian producers, led to the regulatory fast-tracking of pipelines in Canada and ratcheted up the pressure in Canada's already contentious pipeline debate.

Could all of this been avoided? Maybe, if Canada had played one important card, the only one it had left, but refused to use — a price on carbon.

Obama's take on climate change

A depot used to store pipes for TransCanada Corp's planned Keystone XL oil pipeline is seen in Gascoyne, North Dakota, on Nov. 14, 2014. (Andrew Cullen/Reuters) Dennis McConaghy remembers the moment he knew Canada needed a carbon tax if Keystone XL was ever going to be approved. McConaghy was a TransCanada executive and his department came up with the idea for Keystone XL and gained commercial support for the project.

After Obama's speech at Georgetown University in June of 2013, McConaghy realized the writing was on the wall for Keystone XL, even though the project was never mentioned. The speech focused solely on climate change and took aim at fossil fuels.

Dennis McConaghy retired from TransCanada two years ago. His role was to develop new pipeline opportunities, which included Keystone XL 1:38 "This is a challenge that does not pause for partisan gridlock. It demands our attention now. And this is my plan to meet it — a plan to cut carbon pollution; a plan to protect our country from the impacts of climate change; and a plan to lead the world in a coordinated assault on a changing climate," said Obama to applause.

Protesters against the proposed Keystone XL pipeline hold placards in San Francisco in 2013. (Jason Reed/Reuters) McConaghy's new book, Dysfunction: Canada after Keystone XL, looks at how the project was almost built, but fell short. It examines the history of the project, the impacts in Canada and the choices the country now faces. McConaghy left TransCanada two years ago and cut his ties to the oilpatch, although he still holds shares in the Calgary-based company.

KXL's environmental hurdle

The book explores the history of Keystone XL, the impacts on Canada and the decisions the country now faces. Around the time of the Georgetown speech and after it, TransCanada was talking with Harper's government and the main oil industry lobby group, the Canadian Association of Petroleum Producers (CAPP), about how to get Obama onside. McConaghy said company representatives raised the issue of carbon pricing.

"TransCanada tried to work with those two entities to see if any Canadian carbon policy changes could be made," said McConaghy.

Neither Harper nor CAPP had any appetite for a carbon tax, so the decision was made to stay the course. Oil industry players are often hypocrites when it comes to climate change, says McConaghy, because they broadly acknowledge the risks of climate change, but rarely endorse credible policy to deal with the problem.

Harper famously called the project a "no brainer," suggesting the merits of the project were good enough for the pipeline to be approved. There was no need for Canada to do anything else.

The big 'what if?'

To this day, McConaghy wonders whether that decision sealed the pipeline's doom under Obama. A national carbon tax should have been introduced years ago, he says, and it could have saved the project.

"Carbon pricing, in a world that is trying to be serious about dealing with the issue, it was the only alternative for Canada," he says. "That should have been pursued more publicly and with greater conviction as the last card Canada had to play."

[A carbon tax] should have been pursued more publicly and with greater conviction as the last card Canada had to play - Dennis McConaghy , former TransCanada executive

An excerpt from Dennis McConaghy's book "Dysfunction" In his book, McConaghy says Harper's frosty relationship with Obama hurt the prospects of Keystone XL and a victory by then-Liberal leader Stéphane Dion in 2008 may have changed the fortunes of the pipeline proposal because of Dion's ambitious Green Shift policy.

An excerpt from Dennis McConaghy's book "Dysfunction" McConaghy gives some credit to Alberta Premier Alison Redford for trying to increase Alberta's existing carbon tax program for large emitters, although it was only on a provincial scale, not national.

Without a carbon tax in Canada, McConaghy says Obama was not going to approve the pipeline.

"Had Canada actually done that, it might have actually allowed Obama to say within his own country, 'here's the rationalization I have for this approval. They are doing what we ideally would have liked to have done,'" he says.

TransCanada's president and CEO Russ Girling often voiced his frustration with delays in approval of Keystone XL. (Pat Sullivan/Associated Press) "The hand played out as it did and we can see what occurred."

Oilpatch opinion shifts too late

In an ironic twist, when Keystone XL was ultimately rejected a few years later, calls for a carbon tax in Canada began immediately by some political and oilpatch leaders. The appetite for such a policy shift was much stronger. At that time, both former TransCanada CEO Hal Kvisle and the CEO of Royal Dutch Shell Ben van Beurden called for a hefty price on carbon.

McConaghy has faced "enormous" pushback to his book and received criticism from some of his former colleagues, who don't believe a carbon tax would have done anything to convince Obama about Keystone XL. Others, such as former U.S. ambassador to Canada David Wilkins, say there is no point in second-guessing since the decision had nothing to do with Canada, it was all about politics.

The negotiations between Harper and Obama have a parallel in more recent talks among Trudeau, Notley and B.C. premier Christy Clark over the proposed expansion of the Trans Mountain pipeline, although with a different result.

TransCanada's Keystone XL pipeline has been a controversial project in both the United States and Canada. (Tony Gutierrez/Associated Press) Notley announced several climate change measures, including a carbon tax and an emissions cap on the oilsands. Trudeau announced a national carbon tax and other measures to help protect B.C.'s environment. Clark has come around on the project, saying she expects her government will give its provincial approval to the pipeline early in the new year.

Hello, Donald Trump

McConaghy's book is a postmortem of the Keystone XL pipeline, but the recent presidential election is resuscitating the project. Trump is believed to be a proponent and he's appointing several oil industry supporters to his administration.

TransCanada recently made some changes to the project description on its website, so paragraphs written in the past-tense are now in the present. The section explaining the rejection of Keystone XL by Obama is completely removed. It's a hint the project is alive.

McConaghy thinks so too.

"[The Trump administration] will find a way to get it revived," he says.

Even if the long-awaited project is ultimately constructed, McConaghy will still wonder whether it could have been built years ago if only Canada had introduced a carbon tax much sooner. Harper was a strong supporter of the oilpatch, but the book raises the question about whether TransCanada needed a prime minister that would put all the cards on the table, if needed, to convince Obama.

In 2017, Alberta, Ontario, Quebec and British Columbia will have have a price on carbon. The federal carbon tax is expected in 2018.

McConaghy's book will be released Jan. 21.