cancel
Showing results for 
Search instead for 
Did you mean: 

Where to place destination credentials for testing in CAP ?

Attila
Active Participant

Dear CAP Developers,

I'd like to do local testing in VSCode accessing an external S/4HANA OData service on the network during the development phase only.

Entering credentials within the destination in package.json is working , but I want to prevent pushing credentials to GitHub.

As explained in the CAP documentation we can use environment variables as well to save basic authentication credentials referred in the package.json.

"cds": {
    "requires": {
        "REVIEWS": {
            "kind": "odata",
            "model": "srv/external/REVIEWS",
            "[production]": {
                "credentials": {
                    "url": "https://reviews.ondemand.com/reviews",
                    "authentication": "BasicAuthentication",
                    "username": "<set from code or env>",
                    "password": "<set from code or env>",
                    "headers": {
                      "my-header": "header value"
                    },
                    "queries": {
                      "my-url-param": "url param value"
                    }
                }
            }
        }
    }
}

Tried to add the complete destination both to default-env.json and .cdsrc-private.json including the username and password but it was not picked up.

Do You know the way to store the credentials privately in environment variables without explicit coding ?

Thank You

Best regards, Attila

Accepted Solutions (0)

Answers (1)

Answers (1)

lothar_bender
Advisor
Advisor
0 Kudos

Hi Attila,
I assume that Hybrid Testing is what you are looking for...

With hybrid testing capabilities, you can stay in your local development environment and avoid the long turnaround times of cloud deployment, and you can selectively decide which services you want to use from the cloud.

Note: No credentials are saved locally. Only the information about where the credentials can be obtained is stored on your machine.

Regards, Lothar

Attila
Active Participant
0 Kudos

Hi Lothar,

I've tried with that, but due I am using an S/4HANA destination in a subscriber subaccount by a CAPM applications, the hybrid testing is not working in VSCode. I wanted to avoid the workaround with SSH tunneling. That is why I am looking for an alternate solution. Maybe I did not spot out something, but CF blocks external IPs during hybrid development from local computer, therefore I use this alternate way. In BAS - which is on same CF region and not blocked by BTP - it is possible, but a bit complicated to test SaaS solutions, because I have to use chrome extensions to set custom host in HTTP headers, but this definitely kills every other tabs and windows in chrome.

Thank You

Best regards, Attila

nicorunge
Participant

Hi Attila,

you can also set the credentials via your .env file in your package.json like this:

cds.requires.REVIEWS.[development].credentials.authentication=BasicAuthentication
cds.requires.REVIEWS.[development].credentials.username=
cds.requires.REVIEWS.[development].credentials.password=

BR, Nico

Attila
Active Participant

Hi Nico,

this is exactly I wanted. In fact, I was able finally to find the section based on Your answer in the capire documentation, what I was missing for a long time, but could not spot out so far. There are many goodies :)!

Thank you very much for Your support!

Best regards, Attila