Hello everyone.
We are designing a portal for a client using power pages. We have some external APIs by the client (they return PDF). We have done tests with js and everything goes well, we can visualize those pdf.
Using the help of Postman we use Javascript fetch. We do not know how to implement the authentication and the URL in power page, for security we must configure that part.
Also comment that the URL of the queries there are values that we concatenate with code liquid, I explain:
On one page we display the details of a record from our CRM using:
{% if request.params.id %} {% assign invoice = entities['dev_invoice'][request.params.id] %}
This way I can use invoice.dev_numberInvoice inside a variable:
var number = '{{dev_numberInvoice}}'; //dev_numberInvoice is a column of my table
And in the API URL it would be something like this:
var myHeaders = new Headers();
myHeaders.append(
"Authorization",
"tokentokentokentokenslkjdlskdjlsakdj"
);
var requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow",
};
var urlAPI = "https://customercompany.com/api/v1/customer/22/invoice/" number;
fetch(urlAPI, requestOptions)
.then........
You can see that the 22 of the URL can be another field, a lookup
I have been able to do all this within the editor at the bottom of the power page, but of course it would not be correct.
How can I configure the token that this external API gives us in power pages? I have seen Nodejs being used, but I don't know if I can use all of that within the microsoft environment.
Other information I have found is OAuth 2.0 implicit grant flow within your portal, but I'm not sure if inside power pages or make.powerapps.com it can be done.
I would appreciate help or knowing where I can start.
Thank you very much.
Best Regards.