0
votes

I want to create a flow in Microsoft flow that creates a plan in Microsoft planner each time an item is added to a list in SharePoint. There is no action in Microsoft flow you can use to create a plan so I decided to use the Microsoft Graph Api where it IS possible to create a plan. With a http action I'm able to call the API Before you can call the Microsoft Graph API to create a plan you need to follow a few basic steps:

  1. Register your app to authenticate with the Azure v2.0 endpoints.
  2. Configure permissions for Microsoft Graph on your app.
  3. Get administrator consent.
  4. Get an access token.
  5. Use the access token to call Microsoft Graph.

These steps are described into this tutorial: https://developer.microsoft.com/en-us/graph/docs/concepts/auth_v2_service.

The description of how to use the create plan in planner graph API: https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/planner_post_plans#example

The problem that i have is that i can't use the access token to call Microsoft Graph. I'm able to perform all steps except step 5 where I need to use the access token to call microsoft graph. Im having a "401" errorcode "unauthorized". I've been searching to solve this problem for 4 days know but I can't seem to solve it. Underneath you can find screenshots of how my flow looks like:

Thanks in advance!

1
Replace the call Graph to request your profile, if you still cannot do it then it maybe still the configure issue. Although you have register the App but not right configured.Seiya Su
@SeiyaSu How do i request my profile? I'm very new to all this so excuse me if I'm asking a basic question.Jason Robesyn
I didn't make any develop in Office365 in months, but if you are going to work with microsoft flow, i used to read John Liu's blog. It has a nice examples: johnliu.net/microsoft-flowMikel

1 Answers

0
votes

You can follow the below blog to use Graph+MicrosoftFlow,what is missing in your case is get the actual access token:

https://powerusers.microsoft.com/t5/Microsoft-Flow-Community-Blog/Extend-Microsoft-Flow-with-the-Microsoft-Graph-and-0-code/ba-p/61662

  1. In order to use the Microsoft Graph, we need to define an Azure App that will be authorized via OAuth 2.0 by authenticating directly with Azure AD. Set the permission in here. Store secretid and appid.
  2. Create flow. To generate the access token, we can use the out of the box Http action and pass the required parameters to the https://login.microsoftinline.com//oauth2/token url. Get the token.
  3. Use the token to call the Graph.

The full workflow: enter image description here

Another reference:

http://blogopaxio.azurewebsites.net/accessing-graph-api-from-microsoft-flow-using-application-permissions-2/