This is an example of how to consume a CAP service with authentication from on SAP Fiori app.
The managed-html5-runtime-fiori-launchpad-mta sample consumes the Northwind odata.org service, this is a public service without any kind of authentication.
This project mocks the Northwind service, the service is exposed as a CAP service with required authentication. Deploy of this package override the URL of the original Northwind destination with the URL of the mockup service and set the property HTML5.ForwardAuthToken necessary to forward the authentication user from the SAP Fiori app to the CAP service. This property is documented at Configure Destinations
The MTA file bind the CAP service to the xsuaa service already created by the managed-html5-runtime-fiori-mta package.
- Deploy the
managed-html5-runtime-fiori-mta
to you BTP subaccount as explained in the package documentation - Add the entitlement
hana hdi-shared
to your subaccount if you haven't done so before - Build the project:
mbt build
- Deploy in the same subaccount/space of the
managed-html5-runtime-fiori-mta
package:cf deploy mta_archives/cap-service_1.0.0.mtar
To be sure to use the new mock service open an incognito browser window and then access the URL of the HTML5 App of the managed-html5-runtime-fiori-mta
package, you should see the same data, however the product name of the first product will be Hello from CAP, this is the mark that the data are read from the CAP service.