Business Central OAuth2 for Power Automate ๐Ÿ›‚

Generally when writing a post I quickly explain the scenario and get straight to the solution. I need to break that rule here to avoid confusion. As the title suggests this post is about using OAuth2 with Power Automate – applies also to Azure Logic Apps. However, if you have Power Automate flows using the BC connector you are already covered. If you have custom connectors for BC data which use OAuth2 for authentication. You are also covered. So whatโ€™s the point of this blog you ask? If you use the HTTP connector in your flows to interact with BC data – you have opened the right blog post ๐Ÿ‘๐Ÿผ. Why does this post matter? Well at the date of writing, 01/03/22, basic authentication for BC web services is being deprecated ( OAuth2 is the replacement. If you can move away from using the HTTP connector then please do. That way you can just natively pickup the correct authentication. I say there are two main reasons you wouldnโ€™t move things to the BC connector. If you have published a codeunit as a web service or you use query objects (which aren’t the API type). Lesser reasons might be that you donโ€™t have development resource or want to avoid cost of refactoring. After all Power BI get to use legacy web services so Power Automate should get to as well right? For PowerApps you need to use a custom connector or the BC connector. You might have Power Automate flows which run from PowerApps. In which case if they use the HTTP connector, same explanation as above. Woah! ๐Ÿ˜ฎ that was a wordy intro. If youโ€™re still with me letโ€™s get to the good bitโ€ฆ

I will admit early on I only came across my answer thanks to some brilliant blogs! I highly recommend reviewing Arend Janโ€™s posts in particular if you have little background on working/setting up OAuth2 for BC. Links:

The solution is to have a standalone flow which will retrieve the access token. You will use this flow as a child to you main PA flow. This pattern will work well as you don’t have to alter your existing PA flows using the HTTP connector that much. Let’s get the child flow out the way first as that’s the longer part.

Here is the text string from the compose action mentioned in the gallery of images. Replace the your_client_ID and your_client_secret parts to form the correct string:


Now we have the child flow up and running let’s plumb it in to a parent flow ๐Ÿง‘โ€๐Ÿ”ง I will go through each step with images again.

It’s a fairly elegant way to slot in what is needed for the PA flows this might apply to. There are a number of my own previous blog posts which need this solution – like this one:

To make life easy I’ve created a template of the child flow which you could import into your environment. There are setups that need dealing with before it will work though:

One thought on “Business Central OAuth2 for Power Automate ๐Ÿ›‚

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s