Hi everyone, I'm trying to call custom API which I created in solution from power pages. as I have followed Microsoft docs for creating site settings and created app registration in AAD as well still I'm not able to get chances of calling it. Can someone please guide me on how to call api from power pages.
Note: In some references they say to get auth token from portal by <portal_url>/_services/auth/token by pasting url in browser. But for me I never got the token from portal. Is there any configurations
References: https://learn.microsoft.com/en-us/power-pages/security/oauth-implicit-grant-flow
Thank you @KH_2437
Thank you @KH_2437 that was so good information. I tired to to a post request using token url from browser console but I'm getting 404 not found error. But can you please shed some light on APIM? I'm bit curious about this. Because I'm bit new to these and I'm not sure how to validate token in APIM and JWT validate in inbound policies. How to do these things. This will help a lot
Hi @Anonymous
I believe <portal_url>/_services/auth/token only support post now and the browser uses get. You will need to go into the console on the browser and call the post action from there.
When it comes to authentication, using APIM to call your custom API, will allow you validate the power pages token in APIM using JWT validate in the inbound policies. Better to extract the username from the token with in the policy and pass it to your custom API for any authorizations you may need in the custom API.
A question that's probably worth asking though, is it really necessary to use a custom api? You will need to use client side javascript to do so and this carries it's own concerns of where users can manipulate it at the browser. Power pages works best with the data is on dataverse, is it a possibility to copy the required data to there?
Or wait for the new feature due for release to preview shortly where one can call a Power Automate flow that can then call your custom API from power pages. Not sure what the lag will be like on this but if it's fast, it will be very promising for simplifying the whole area. Use cloud flows with Power Pages sites
Regards
WarrenBelz
9
Most Valuable Professional
Fubar
6
Super User 2025 Season 1
Rondel
6