cancel
Showing results for 
Search instead for 
Did you mean: 

How to create ui5 for API Business hub identity authentication

sylvia_guirguis
Explorer
0 Kudos

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).

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


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);
}

Accepted Solutions (0)

Answers (0)