And that is a good thing, because the rest of the book — overviews of Mr. Obama’s handling of Afghanistan, Pakistan, the Arab Spring, and China and North Korea — offers a solid but rather dutiful summary of this administration’s foreign policy. As I read it, I wondered if the author — in the course of working on a book to be titled something like “The Education of a President” — had come across the extraordinary material on the cyberwar against Iran.

Those other spinach-laden sections are not bad, but they are not as compelling as Mr. Sanger’s guided tour of the anti-Iranian operations. He offers a healthy meditation on Mr. Obama’s heavy use of drone strikes in Pakistan, asking how such strikes differ from a program of targeted assassination, if at all. And throughout, Mr. Sanger clearly has enjoyed great access to senior White House officials, most notably to Thomas Donilon, the national security adviser.

Mr. Donilon, in effect, is the hero of the book, as well as the commenter of record on events. He leads the team that goes to Israel and spends “five hours wading through the intelligence in the basement of the prime minister’s residence.” He is shown studying the nettlesome problems of foreign relations, working closely with the president, and fending off the villains of this story — which in Mr. Sanger’s account tend to be the government of Pakistan and, surprisingly, the generals of the American military. “We fought the Pentagon every step of the way on this,” a “senior American diplomat” tells Mr. Sanger. At another point, a “senior White House official” reports that, “There was incredible resistance inside the Pentagon.” And so on.

The virtue of this book — its foundation of White House sources who give the author insiders’ material like a transcript of Mr. Obama’s last telephone call with the Egyptian president, Hosni Mubarak — is also its weakness. That is, Mr. Sanger shows us the world through the eyes of Mr. Obama, Mr. Donilon and those around him. But he also tends to depict Washington and the world as they see it. The perceptions of White House officials, especially in the first year of the Obama presidency, which saw a steep learning curve for the president and those around him, are not always dispositive.