Using Graph in MS Flow (Bearer Token)

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…

Solution:

  1. register an app on https://apps.dev.microsoft.com/
    make sure, you grant the application appropriate permissions in Azure AD. In my case it was “User.ReadWriteAll” (application permission!)
    then generate a password and also note down the application ID (you need it later);
    in Azure AD grant the application the admin consent for the permissions!
  2. In Flow add an action “HTTP Request”
    Note that the body content must be URL encoded
  3. Now you have to get the token out of the response;
    use the action Initialize Variable and a custom expression
    (where ‘GetAccessToken’ is the name of the action from before!)
  4. again use an action HTTP Request to do the POST
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 4.50 out of 5)
Loading...

MS Flow – Calculating DateTime Difference

Problem:

I needed something like calcDateTimeDiff formula, but wasn’t available in Flow.  The data source in my case was a SharePoint list and I wanted to write the time difference (daily work time) back to the list in a string column.

Solution:

1. calculate the datetime difference in ticks() format – yes, that’s the trick!
One tick = 1 nanosecond
sub(ticks(item()[‘stEnd’]),ticks(item()[‘dtStart’]))

2.  Starting the day at 00:00 and add the seconds, then define the output format (1 second = 10.000.000 ns)
addSeconds(’00:00:00′,int(div(int(variables(‘testDiffDate’)),10000000)),’HH:mm:ss’)

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)
Loading...