cancel
Showing results for 
Search instead for 
Did you mean: 

ODataModel constructor authentication not working?

rpanneel
Participant
0 Kudos

Hi all,

I've ran into a small issue with my SAPUI5 code. I've created a very simple SAP NetWeaver Gateway service and I am able to test this via restclient (in chrome or via the application).

Now when I do the following in my sapui5 controller

showSecondPage: function() {
   var oAppData = sap.ui.getCore().getModel("app").getData();
   var oModel = new sap.ui.model.odata.ODataModel(oAppData.BaseURL, false, "user", "password");
  sap.ui.getCore().setModel(oModel);
   sap.ui.getCore().getEventBus().publish("nav", "to", {
        id : "ProductList"
    });
}

Then I get following error on chrome when testing it

In the developers tool (Network section) i see that the $metadata call is formatted this way:

<user>:<password>@server:port/sap/opu/odata/sap/<GW_SERVICE>/$metadata

And the response for this call is the login-form from SAP

The thing is when i open another tab in chrome and go manually to the metadata url and log in there it just works.

So did i forget to do something in my code to get through this loginform directly by the ODataModel constructor?

Thanks in advance.

Kind regards,

Robin

Accepted Solutions (1)

Accepted Solutions (1)

former_member182650
Contributor
0 Kudos

Check this:

1. Gateway service has not defined an incorrect / hardcoded logon user in service runtime configuration.

2. User exists and isn't locked in Gateway System.

3. Try to introduce the same URL in navigator. The same behavior is produced with other user with SAP all authorization?

Kind regards

rpanneel
Participant
0 Kudos

The weird thing is when i navigate to the service document that I receive a logon screen

I don't think that this is normal no?

Shouldn't I receive a popup for asking credentials? The ODataModel constructor gives also this screen as response (network tab of google chrome developer tools) instead of the metadata document.

My user isn't locked, has SAP_ALL. And when i log in into that screen i receive the service document and can do everything I want.

Any idea?

Kind regards,

Robin

rpanneel
Participant
0 Kudos

I have found the solution, it seemed that in the configuration of the gateway a small mistake was made.

Once I discovered and corrected this it works as it should be in both the browser ($metadata call) and in the gateway code.

Thanks for the assistance.

Kind Regrads,

Robin

Answers (1)

Answers (1)

kammaje_cis
Active Contributor
0 Kudos

I feel that problem is with "oAppData.BaseURL". This URL may not be pointing right .

Can you put a breakpoint and check it?

rpanneel
Participant
0 Kudos

Thanks, I just doublechecked it:

The url in the oAppData.BaseURL variable is the correct one... on this url I can see the service document for the service.

The code stops on the ODataModel constructor, so the setModel(oModel) line is not reached. Because the sap login page is being called.

Any idea's