My previous post illustrated how to use the Microsoft Graph in your Flows without having to create a custom connector/server side code. My favorite server side code is an Azure function written in PowerShell or in C# ( I know I should try Node.js).
One of the challenge of using the Microsoft Graph is we need to get an Azure/oAuth2.0 access token (see last post).
To make it easier and reusable, I decided to isolate the access token generation code in what I call a "Service Flow", which is a Flow that can be invoked via the Http flow action and can return a value + a status if needed (it can also be a fire and forget service flow if we not interested in any return value.
The Flow must start with the "When a HTTP request is received" action and can be ended with the Response action (renamed here as "Return Access Token'.
Let's get into the detail :
The Access token generation :
Parsing the returned values:
The associated schema is here :
And the access token is returned here:
Now the calling workflow (described in my previous post) looks like this:
The call to the ServiceFlow is detailed here:
I think it is a good practice to create reusable services with Microsoft Flow. Of course in many cases an Azure function will be good enough, but in some companies it is not that easy to have an Azure account or it is complicated to use this Azure account as a developer, so we must use the tools we have at our disposal 🙂