
#Node http client install#
The content of the files can be found in the appendix.įor your convenience, I’m pasting a screenshot:Īfter creating the files, we need to install the modules locally. To host our files, we create a folder, e.g. The description is based on the command line tool for Cloud Foundry.Īlternatively, the cockpit of SAP BTP can be used to create the service instance and service key. However, this means that we need to create a service key in addition to the service instance.īelow is the description for creating both. We want to run our code locally, to make things easier. We need to create an instance of the XSUAA service, which will act as server and which will provide us with the required credentials. Preparationįor those who wish to follow the example, here’s the description: However, the code should work with any other server as well, so you can just copy the snippets and don’t need extra cloud access. This tutorial is based on trial account in SAP BTP. In order to follow the description, you need access to SAP BTP, and permission/quota for creating the service instance. You can find basic information about certificates in this blog post. This blog post assumes that you’re Node.js user and a bit familiar with certificates. If not, please add your sample code in the comment section. I hope to somewhat meet your expectations…. I’m posting 4 samples that are based on different libraries, including the native way. However, if desired, it is easy to modify the code such that it runs in the cloud.

We don’t need to deploy an app, as such we can keep the code minimalistic. Our client code is just a script which we can run from our local laptop.

I’ve chosen this scenario because it is real use case and it is easy to reproduce for anybody. The HTTP request is successful (and we’re satisfied) if the request returns a valid response (containing a token). The credentials which we need (certificate) are given to us by the service instance. The HTTP request we’re sending is used to fetch a token.

The server which receives our HTTP request is the XSUAA service. We’re executing an HTTP request from client to server.
#Node http client how to#
This blog post contains sample code (node.js) showing how to execute an HTTP request that authenticates with client certificate instead of user/password.Īs example setup, we’re using the SAP Business Technology Platform (SAP BTP, fka SAP Cloud Platform). Need to fire request with client certificate?
