web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Flow trigger "When a H...
Power Automate
Unanswered

Flow trigger "When a HTTP request is received" and "Any user in my tenant"

(0) ShareShare
ReportReport
Posted on by 2
I have a flow with the "When a HTTP Request is received" trigger and want to use the "Any user in my tenant" option, so that it cannot be called anonymously.
 
I have created the necessary App Registration in Azure, created a client secret, and  given the app registration the correct permission to use Power Automate.
 
Does anyone have an example of how to build the some client-side JavaScript code to call the Flow, passing in the necessary OAuth authentication values? I have seen plenty of examples using Postman, but no examples of any JavaScript making the call.
 
Example using Postman
 
This announcement and the documentation don't show you how to do it from Javascript calling code, on the client
 
 
Thank you in advance
Categories:
I have the same question (0)
  • Pete_L Profile Picture
    2 on at
    I worked this out, so I am answering my own question, in case it helps others:
     
    First, in JavaScript, you have to make a call to get a Bearer token. Then add the value of that token to the headers of the JavaScript request to the Flow. The "code" option in Postman helps to generate the necessary JavaScript (or many other languages) to make the call. The redacted code is below - I have redacted the full body of the very long token and the URL of my Flow, and I have used an example URL variable name, to show a parameter being passed into the Flow.
     
    In reality, you would not hard code the token, you would make a JavaScript call to get it. You would supply these values to get the token:
    • GET: https://login.microsoftonline.com/[TenantID]/oauth2/v2.0/token
    • grant_type: client_credentials
    • client_id: your clinet (application) id from Azure
    • client_secret: the secret, from Azure
    • scope: https://service.flow.microsoft.com//.default
    • See video in main post for how to do this
    const myHeaders = new Headers();
    
    //Then use the value of the token in the "append" method, to the headers
    //Note there is a space between the word Bearer and then the actual token which begins eyJ0ein this instance
    myHeaders.append("Authorization", "Bearer eyJ0e....[REDACTED TOKEN - LONG TOKEN TEXT HERE]");
    
    const requestOptions = {
      method: "GET",
      headers: myHeaders,
      redirect: "follow"
    };
    
    fetch("[Redacted URL of FLow]/triggers/manual/paths/invoke?api-version=2016-06-01&myURLvariablePassedToFlow=12345", requestOptions)
      .then((response) => response.text())
      .then((result) => console.log(result))
      .catch((error) => console.error(error));
     
  • sarah483 Profile Picture
    2 on at
    Hello Pete,
     
    I have a Power Automate flow with the HTTP trigger that can be triggered by "Any user in my tenant".
     
    I've created an App Registration in Azure, and I'm able to get the token using Postman and use that token in my JavaScript web resource.
    Since I can't use always the same token in my code because it expires, I have to make an HTTP call (similar to the one I'm making in Postman) to get the token and then use in the HTTP call that triggers the flow (I'm using the same code that you've shared).
     
    Can you help me with the JavaScript function to get the token? I'm not able to do it in my web resource, since the code is giving me errors.
    If you can, please share me the code that you've used to get the token!
     
    Thanks :)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 462 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 456 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard