He served as a Massachusetts state senator and a U.S. senator , and then , during James Monroe 's presidency , as secretary of state , where he was largely responsible for formulating the principles behind the Monroe Doctrine .
He had a lengthy and successful career as a state senator and secretary of state .