How to Generate a Bearer Token in Power Automate

In this tutorial, we are going to show you how to create an API connection for your Teams bot and how to generate a bearer token in Power Automate.

We will be using an OAuth 2.0 connection. First click on the API access in the left hand menu. Select the OAuth option. Name your API connection and make sure that Client Credentials is selected.


You will now be presented with the following screen:


Make sure that you copy the Client ID and Client Secret and store them safely as they will not be shown again. That is all you need to do in order to set up your Teams bot to work with our API.

Now we need to use Power Automate to generate our Bearer token. The Bearer token is needed to securely interact with The Bot Platform API. The bearer token expires after 60 minutes, so it needs to be refreshed every 61 minutes in order for your API connections to continue to work.

First we want to go into Power Automate and select create a new flow. You want to create a scheduled flow.

Give your flow a name and set it to the current date and time to start. You want to set it to run every 61 minutes.


Click the create button and you will then see your new flow.


Now you want to add a New Step and choose a HTTP module.


The Method needs to be set to POST.

Your URL needs to be

You need to add two headers:

Content-Type which needs to be application/x-www-form-urlencoded

Accept which needs to be application/json

Then in your body type, you need to enter the following:


Copy the client Id and add that in place of CLIENTID and copy the client secret and replace that in the above text.

When completed, it should look as shown below: