sap-tutorials / Issues

Creative Commons Attribution 4.0 International
8 stars 5 forks source link

Add User Authentication to Your Application (SAP HANA Cloud) #707

Closed Mat-byte closed 1 year ago

Mat-byte commented 1 year ago

Tutorial: https://developers.sap.com/tutorials/hana-cloud-cap-add-authentication.html#9c3c20cd-f21b-438b-9029-34ff7adc1549

Hi, Can you support me with my issue? I did all the tutorial and the port5000 response: image

This is my configuration: image

Also, the link with cf looks good: image

Thanks in advance-

jung-thomas commented 1 year ago

If you add the path (/interaction_items/webapp/index.html) to the URL that opens - does that work?

Mat-byte commented 1 year ago

Hi @jung-thomas , thanks for the quickly reply. It doesn't work. It's weird because if I add /user-api/attributes it shows me : image

jung-thomas commented 1 year ago

". It doesn't work." Does it load the HTML page but give you an error on the service call? Or do you continue to get the bad gateway message?

Mat-byte commented 1 year ago

I keep getting "Bad gateway" message

jung-thomas commented 1 year ago

Could you please share what's in your xs-app.json file in the /app folder.

What I'm confused by: your application router must be running and it is connected to the xsuaa correctly. Otherwise, the call to the /user-api/attributes would fail. I kind of assumed your connection between the application router and the CAP service was the issue. But in that situation, the HTML content from the Application Router would still load correctly but you would get an error message when calling the OData service. Yet you are getting a Bad gateway when just trying to load static html content from the application router. Therefore it seems the issue has to be with the application router configuration still.

Mat-byte commented 1 year ago

Yes Jung, it must be the application router because when I run through the 4004 port, it open ok, and if I try to open the interactions_times it raise "Unauthorized" which is correct. image

It is my xs-app.json: image

Mat-byte commented 1 year ago

Hi @jung-thomas , it's my repository in case it can give you more information: https://github.com/Mat-byte/CAP-HANACloud

Thanks!

jung-thomas commented 1 year ago

There's nothing wrong with the code or configuration in your project. I took your project from GitHub and cloned it into my workspace. I then ran the cds bind to my existing service instances. image

I recreated the default-env.json in the /app folder (because that is filtered out of git commits).

I then run your app without any other changes and it works perfectly fine. image

The ONLY thing that I can see that is different is that I'm using the Free Tier and you are using the Trial. I don't know if there is some technical limitation of the trial that's stopping this from working. That's about all I can think of at this point. Or some bug in BAS itself that's only in the trial landscape but not the production landscape (free tier is production landscape - trial has its own separate landscape).

I'm curious when you do Help->About in the Business Application Studio -- what version is shown? Here is mine: image

ubheamar commented 1 year ago

I was also facing this issue. but its working fine now. I am using 2 command prompt to run application 1 command : npm run app:run package.json script "app": "npm start --prefix app", "app:run": "cds bind --exec npm run app", 2.command prompt: npm run watch-hybrid package.json script "watch-hybrid": "cds watch --profile hybrid",

@jung-thomas is this correct way to run it?

jung-thomas commented 1 year ago

Yes it is actually required to use two command prompts. Both the CAP Service and the App Router have to be running at the same time for this to work. They are two separate applications.

Mat-byte commented 1 year ago

I tried what Ubheamar recommends but it didn't work.

It is my version: image

Something to add: This is my app/default-env.json...Should this file have something else? image

The "VCAP_SERVICES" was something that I added because I saw it on a SAP video. If I delete that part and run again npm install inside app folder, and then run cds bind --exec...... Now it work: image

But if I try to open Interactions_Headers it is shown : image

It's very confusing because I follow the tutorial step by step. Any advice will be appreciated.

jung-thomas commented 1 year ago

No you don't need the VCAP_SERVICES section in the default-env.json.
The acquiring client from the pool is a different message than what you were saying earlier. That probably means you can't connect to your HANA DB. Remember in both trial and free tier that HANA is shut down every night automatically. You have to manually restart it each day.

Mat-byte commented 1 year ago

Now it's working. My bad. Thank you Jung.