{"id":205,"date":"2019-01-18T13:36:58","date_gmt":"2019-01-18T13:36:58","guid":{"rendered":"http:\/\/4us2use.at\/?p=205"},"modified":"2019-04-16T08:58:23","modified_gmt":"2019-04-16T08:58:23","slug":"using-graph-in-ms-flow-bearer-token","status":"publish","type":"post","link":"http:\/\/4us2use.at\/?p=205","title":{"rendered":"Using Graph in MS Flow (Bearer Token)"},"content":{"rendered":"<p>Problem:<\/p>\n<p>I had the need to give our users a way, to register external users through the SharePoint interface for a custom solution also based on SharePoint.<br \/>\nIt was a little bit tricky to get a token from Graph to use it in the next action.<br \/>\nTo save your time, I document it here&#8230;<\/p>\n<p>Solution:<\/p>\n<ol>\n<li>register an app on\u00a0https:\/\/apps.dev.microsoft.com\/<br \/>\nmake sure, you grant the application appropriate permissions in Azure AD. In my case it was &#8220;User.ReadWriteAll&#8221; <em>(application permission!)<\/em><br \/>\nthen generate a password and also note down the application ID (you need it later);<br \/>\nin Azure AD grant the application the admin consent for the permissions!<\/li>\n<li>In Flow add an action &#8220;HTTP Request&#8221;<br \/>\nNote that the body content must be URL encoded<br \/>\n<img loading=\"lazy\" class=\"alignnone size-full wp-image-206\" src=\"http:\/\/4us2use.at\/wp-content\/uploads\/2019\/01\/graph01.png\" alt=\"\" width=\"591\" height=\"397\" srcset=\"http:\/\/4us2use.at\/wp-content\/uploads\/2019\/01\/graph01.png 591w, http:\/\/4us2use.at\/wp-content\/uploads\/2019\/01\/graph01-300x202.png 300w\" sizes=\"(max-width: 591px) 100vw, 591px\" \/><\/li>\n<li>Now you have to get the token out of the response;<br \/>\nuse the action Initialize Variable and a custom expression<span style=\"font-size: 1rem;\"><span style=\"font-size: 1rem;\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-210\" src=\"http:\/\/4us2use.at\/wp-content\/uploads\/2019\/01\/graph02-1.png\" alt=\"\" width=\"591\" height=\"157\" srcset=\"http:\/\/4us2use.at\/wp-content\/uploads\/2019\/01\/graph02-1.png 591w, http:\/\/4us2use.at\/wp-content\/uploads\/2019\/01\/graph02-1-300x80.png 300w\" sizes=\"(max-width: 591px) 100vw, 591px\" \/><br \/>\n<em>(where &#8216;GetAccessToken&#8217; is the name of the action from before!)<\/em><\/span><\/span><\/li>\n<li>again use an action HTTP Request to do the POST<br \/>\n<img loading=\"lazy\" class=\"alignnone size-full wp-image-212\" src=\"http:\/\/4us2use.at\/wp-content\/uploads\/2019\/01\/graph03.png\" alt=\"\" width=\"590\" height=\"535\" srcset=\"http:\/\/4us2use.at\/wp-content\/uploads\/2019\/01\/graph03.png 590w, http:\/\/4us2use.at\/wp-content\/uploads\/2019\/01\/graph03-300x272.png 300w\" sizes=\"(max-width: 590px) 100vw, 590px\" \/><\/li>\n<\/ol>\n<span id=\"post-ratings-205\" class=\"post-ratings\" data-nonce=\"03f8edb7cd\"><img id=\"rating_205_1\" src=\"http:\/\/4us2use.at\/wp-content\/plugins\/wp-postratings\/images\/stars\/rating_on.gif\" alt=\"1 Star\" title=\"1 Star\" onmouseover=\"current_rating(205, 1, '1 Star');\" onmouseout=\"ratings_off(4.5, 5, 0);\" onclick=\"rate_post();\" onkeypress=\"rate_post();\" style=\"cursor: pointer; border: 0px;\" \/><img id=\"rating_205_2\" src=\"http:\/\/4us2use.at\/wp-content\/plugins\/wp-postratings\/images\/stars\/rating_on.gif\" alt=\"2 Stars\" title=\"2 Stars\" onmouseover=\"current_rating(205, 2, '2 Stars');\" onmouseout=\"ratings_off(4.5, 5, 0);\" onclick=\"rate_post();\" onkeypress=\"rate_post();\" style=\"cursor: pointer; border: 0px;\" \/><img id=\"rating_205_3\" src=\"http:\/\/4us2use.at\/wp-content\/plugins\/wp-postratings\/images\/stars\/rating_on.gif\" alt=\"3 Stars\" title=\"3 Stars\" onmouseover=\"current_rating(205, 3, '3 Stars');\" onmouseout=\"ratings_off(4.5, 5, 0);\" onclick=\"rate_post();\" onkeypress=\"rate_post();\" style=\"cursor: pointer; border: 0px;\" \/><img id=\"rating_205_4\" src=\"http:\/\/4us2use.at\/wp-content\/plugins\/wp-postratings\/images\/stars\/rating_on.gif\" alt=\"4 Stars\" title=\"4 Stars\" onmouseover=\"current_rating(205, 4, '4 Stars');\" onmouseout=\"ratings_off(4.5, 5, 0);\" onclick=\"rate_post();\" onkeypress=\"rate_post();\" style=\"cursor: pointer; border: 0px;\" \/><img id=\"rating_205_5\" src=\"http:\/\/4us2use.at\/wp-content\/plugins\/wp-postratings\/images\/stars\/rating_half.gif\" alt=\"5 Stars\" title=\"5 Stars\" onmouseover=\"current_rating(205, 5, '5 Stars');\" onmouseout=\"ratings_off(4.5, 5, 0);\" onclick=\"rate_post();\" onkeypress=\"rate_post();\" style=\"cursor: pointer; border: 0px;\" \/> (<strong>2<\/strong> votes, average: <strong>4.50<\/strong> out of 5)<br \/><span class=\"post-ratings-text\" id=\"ratings_205_text\"><\/span><\/span><span id=\"post-ratings-205-loading\" class=\"post-ratings-loading\"><img src=\"http:\/\/4us2use.at\/wp-content\/plugins\/wp-postratings\/images\/loading.gif\" width=\"16\" height=\"16\" class=\"post-ratings-image\" \/>Loading...<\/span>\n","protected":false},"excerpt":{"rendered":"<p>Problem: I had the need to give our users a way, to register external users through the SharePoint interface for a custom solution also based on SharePoint. It was a little bit tricky to get a token from Graph to use it in the next action. To save your time, I document it here&#8230; Solution: &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/4us2use.at\/?p=205\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Using Graph in MS Flow (Bearer Token)&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[11,6],"tags":[],"_links":{"self":[{"href":"http:\/\/4us2use.at\/index.php?rest_route=\/wp\/v2\/posts\/205"}],"collection":[{"href":"http:\/\/4us2use.at\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4us2use.at\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4us2use.at\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4us2use.at\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=205"}],"version-history":[{"count":7,"href":"http:\/\/4us2use.at\/index.php?rest_route=\/wp\/v2\/posts\/205\/revisions"}],"predecessor-version":[{"id":229,"href":"http:\/\/4us2use.at\/index.php?rest_route=\/wp\/v2\/posts\/205\/revisions\/229"}],"wp:attachment":[{"href":"http:\/\/4us2use.at\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4us2use.at\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=205"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4us2use.at\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}