on 01-10-2015 10:55 AM
Hi Experts,
We are developing an UI5(Fiori Like app) packed with phonegap. We want to set up basic Authentication for the app to connect to the oData provider (its not an SAP backend, just an own provider). But I cant send out the user/pw in the header. even I'm using the following:
var url = "https://urltotheserver";
var oModel = new sap.ui.model.odata.ODataModel(url, true, "User", "Pw");
Do you have any suggestions? I want to avoid using proxy.
Thanks
Might be due to cross domain issue, if setting in the header as per Dennis suggestion, you might want to try setting the bWithCredentials flag.
JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.model.odata.ODataModel
{boolean} | bWithCredentials? | (optional, experimental) true when user credentials are to be included in a cross-origin request. Please note that this works only if all requests are asynchronous. |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Jason, it was helpful, I think it will work, but now I have the following error: A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header
I've added the following to the code:
var headers ={};
headers.Authorization = "Access-Control-Allow-Origin: *.netlife.hu";
headers.setHeader = "X-Requested-With: JSONHttpRequest";
headers.setHeader = "Content-type: application/x-www-form-urlencoded";
var oModel = new sap.ui.model.odata.ODataModel(url, true, "Usr", "Pw", headers, false, true);
But I get this error.
Do you have any ideas?
Hi David,
I don't you can use wildcards when using credentials. If you are using phonegap, perhaps you can use the whitelist to get around the cross domain issues?
http://docs.phonegap.com/en/1.9.0/guide_whitelist_index.md.html
Regards,
Jason
HI David
Have you try
oModel = new sap.ui.model.odata.ODataModel(url, true, null, null, {Authorization: "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="});
where QWxhZGRpbjpvcGVuIHNlc2FtZQ== is encoded username:password string
Thanks
-D
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
92 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.