Skip to Content
0
Jan 12 at 11:59 PM

How to create ui5 for API Business hub identity authentication

83 Views Last edit Jan 13 at 12:32 AM 13 rev

I am creating a Fiori App calling the API for the Authentication Service. I did a trial in the SAP Business Hub and the GET and DELETE Requests are working (200 OK).

grafik.png

However, i followed this tutorial to create a firori app. i copied the snippet code of the GET request as explained in step two and removed xhr.setRequestHeader("DataServiceVersion", "2.0" from the onInit function to unlock the CORS policy.

Unfortunately i get the CORS Missing Allow Origin

https://developers.sap.com/tutorials/productconfiguration-ui5-app-create.html

grafik.png


onInit: function () {
  var data = JSON.stringify();
  var password = " ** ";
  var userName = " ** ";
  var credentials = userName + ":" + password;
  var hash = btoa(credentials);
  var auth = "Basic" + hash;
  var xhr = new XMLHttpRequest(); 
  xhr.withCredentials = true;
  xhr.addEventListener("readystatechange", function () {
     if (this.readyState === this.DONE) { 
         console.log(this.responseText);
      } 
   });
  //setting request method //API endpoint for API sandbox 
xhr.open("GET", "https:// ** .accounts.ondemand.com/scim/Users");
  //adding request headers 
xhr.setRequestHeader("config_authType", "Basic");
xhr.setRequestHeader("Authorization", auth);
xhr.setRequestHeader("config_packageName", "SCPIdentityServices");
xhr.setRequestHeader("config_actualUrl", "https:// ** .accounts.ondemand.com/scim"); 
xhr.setRequestHeader("config_urlPattern", "https://{tenant}.{host}/scim");
xhr.setRequestHeader("config_apiName", "IdDS_SCIM"); 
 //xhr.setRequestHeader("DataServiceVersion", "2.0"); 
xhr.setRequestHeader("Accept", "*/*"); 
xhr.setRequestHeader("APIKey", " ** ");
 //sending request 
xhr.send(data);
}

Attachments

grafik.png (197.9 kB)
grafik.png (173.6 kB)