Generate Authentication Bearer Token in Power Automate using Azure App Registration

Rehan Memon
3 min readJan 23, 2023

The process of getting a bearer token in Power Automate Flow from Azure App Registration can be a bit confusing at first, but with a few simple steps, you’ll be able to get the token you need to access your Azure resources.

  1. First, you’ll need to create an Azure App Registration for your application. You can do this by going to the Azure portal, and selecting “Azure Active Directory” from the navigation menu.

2. Next, select “App registrations” and then “New registration”. Give your application a name, and select “Accounts in any organizational directory” as the supported account type. Click “Register” to create your application.

3. Once your application is created, you’ll be taken to the “Overview” page for your application. Here, you’ll find the “Application (client) ID” for your application. Make sure to copy this value as you’ll need it later.

4. Next, you’ll need to create a secret for your application. To do this, select “Certificates & secrets” from the navigation menu, and then select “New client secret”. Give your secret a name and an expiration date, then click “Add” to create the secret.

5. Once your secret is created, you’ll be able to see the value of the secret. Make sure to copy this value as you’ll need it later.

6. Now that you have your application ID and secret, you can use these values to get a bearer token. To do this, you’ll need to make a post request to the Azure Active Directory token endpoint with the following values:

  • grant_type: “client_credentials”
  • client_id: “your application ID”
  • client_secret: “your secret”
  • resource: “https://management.azure.com/"

7. Now we can go ahead to Create the Power Automate Flow based on your requirement you can choose the trigger.

8. Add a “HTTP” action to the flow and configure it to make a POST request to the Azure Active Directory token endpoint.

In the “URI” field, enter the following: https://login.microsoftonline.com/yourtenantid/oauth2/token

In the “Headers” section, add the following key-value pair:

Content-Type : application/x-www-form-urlencoded

In the “Body” section, add the following key-value pairs and Replace the clientIDValue(from Step 3) and clientSecretValue (from Step 5)

grant_type=client_credentials
&client_id=clientIDValue
&client_secret=clientSecretValue
&scope=https://graph.microsoft.com/.default

When we run this, we see we get back the Bearer token:

Thank you for reading and we hope this blog post was helpful. Stay tuned for more Power Platform tips and tricks!

If you found this useful and would like to connect !

Please feel free to reach out via LinkedIn | Email

--

--