cancel
Showing results for 
Search instead for 
Did you mean: 

HANA XS JavaScript Destination with base authentication

andreas_morf2
Explorer
0 Kudos

Hi there,

I am searching for an example on the Web which explains me how to use XS JS HTTP Destinations with a URL that has authentication set to "base" and needs to access the content from a url which can only be access by username and password.

The configuration syntax of .xshttpdest Files is linked here: https://help.sap.com/saphelp_hanaplatform/helpdata/en/6e/fe500d91ee462c85cce7609646e17a/frameset.htm

All the public examples like e.g. https://help.hana.ondemand.com/help/frameset.htm?06ca24043b0f4eb78cf39c6bc1d8a8dc.html show only the easy cases with "authType=none" and I never found an example with "authType=basic".

The JavaScript API for HANA XS is not so extensive and hence I have my problems in setting HTTP request headers in JavaScript:

http://help.sap.com/hana/SAP_HANA_XS_JavaScript_API_Reference_en/$.net.Destination.html

I would like to write something similar to

req.headers.set("Authentication", "Basic " + base64_encode("USER:PASSWORD")) but I didn't find any example yet for this and my trials won't work. Can someone support here which is more experienced with HANA XS Destinations?

View Entire Topic
JonasK
Advisor
Advisor

Hi Andreas!

You can configure the .xshttpdest with basic authentication by setting authType = basic; in the file.

What you need to do then in addition is to configure the username and password for this destination using the XS Admin Tool (<server:port>/sap/hana/xs/admin). You navigate to your .xshttpdest file and provide the credentials there.

Afterwards, the server takes care of authentication with the stored credentials when you use the destination with the $.net API.