In this post, we will look at how to get a Bearer token in a Power Automate flow.
First, we will create a new Instant flow in Power Automate:
And we will trigger it manually:
Now let’s add a new HTTP connector:
Now, following along from a previous post where we get the Bearer token to use in Postman, we will set the method = POST and the URI = the microsoftonline URI with our tenant:
Now, for the Header, the Content-Type = application/x-www-form-urlencoded, and the Body will contain a string in the format grant_type=client_credentials&client_id={clientid}&client_secret={clientsecret}&resource={resource}:
When we run this, we see we get back the Bearer token:
I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.
IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.
THANK YOU, AND LET'S KEEP LEARNING TOGETHER.
CARL
What is the resource?? I have my client ID and client secret, but I don’t know what the resource is?
I have the same issue, did you solve this?
Any update I also don’t know what resource is.
This is working successfully for us, but we need to get a token on behalf of a user. Is there a pattern you have worked with to pass in the user context that is executing the flow – On behalf of a user?
Could you please tell us more on where should I put in the details like access_Token, token type, expires-in in the body of the HTTP request? is it going to be picked up automatically based on URI? I dont have resource value data.
use scope instead of resource
scope=https://graph.microsoft.com/.default
this worked for me!
Hi
How can I grab the access token from the body and put it in a variable?
Next step in my flow I would like to use this token in another http request
Hello , How to Generate a Bearer Token in Power Automate desktop