Showing results for 
Search instead for 
Did you mean: 

Generate an Azure OAuth2.0 Token from a "service" Flow and keep your Flows simple

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 associated schema is :



The Access token generation :


generate access token


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 🙂


Hi Team,


I have a requirement that needs to connect an application deployed at Azure from Microsoft Flow. I am using the below reference for the same:


I am using grant_type=client_credentials along with the parameters required like client_id, client_secret and resource.


The issue I was facing is: The Bearer token I am getting in above step is not able to call the api that I need. Please find below screen shots of my flow for your understanding:




From the above step I am getting the Bearer token, I am using this Bearer token to call the rest service.



But I am getting an error that Access Denied Error.






My question is to use grant_type=client_credentials, Is there anything I need to setup at Azure level?


Thanks in advance.










after getting the access_token from the Get call for the 1st HTTP call. I tried to put the bearer token in header of HTTP call, it is error out with non authorized error message. i also try to put in the body, it failed too.  any ideas how to send this bearer token access in Get call. Thanks

Meet Our Blog Authors
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Cambridge UK Power Platform User Group Leader, Technical evangelist and speaker. Always says yes to coffee! #LetsGetCoffee
  • Passionate #Programmer #SharePoint #SPFx #Office365 #MSFlow | C-sharpCorner MVP | SharePoint StackOverflow, Github, PnP contributor
  • I am building business processes and applications that are easy for users' to stick to, so they can follow and understand them. In overall I transform processes to be more reliable and effortless. I am a proud co-organizer of SharePoint Saturday Warsaw and active community member, blogger and international speaker.