Skip to main content
Community site session details

Community site session details

Session Id : EHXQkVSEqcRTp6JzmNn2gw
Power Automate - Building Flows
Unanswered

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

Like (0) ShareShare
ReportReport
Posted on 11 Nov 2024 01:04:31 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:
  • sarah483 Profile Picture
    2 on 22 Jan 2025 at 10:33:21
    Flow trigger "When a HTTP request is received" and "Any user in my tenant"
    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 :)
  • Pete_L Profile Picture
    2 on 11 Nov 2024 at 08:51:30
    Flow trigger "When a HTTP request is received" and "Any user in my tenant"
    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));
     

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

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 986 Moderator

#2
stampcoin Profile Picture

stampcoin 699 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 577 Super User 2025 Season 2

Loading complete