Login operation in OpenSearch API

Hi,

I would like to access the Sentinel Product Catalogue throught the OpenSearch API deployed on
https://scihub.copernicus.eu/apihub/search

Some API basic documentation is available under:
https://scihub.copernicus.eu/twiki/do/view/SciHubWebPortal/APIHubDescription

There are some shell scripts for data discovery, and some URLs to query products by attributes (time range, product, area of interest, etc.) However, it is not mentioned how to generate an HTTP login request

From the web interface (Copernicus Open Access Hub, accessible from https://scihub.copernicus.eu/dhus ), i can track the HTTP network to see the parameters required by the server to authenticate an user. It seems that it is mantadory to send in a form data login and password, plus a _ga cookie, which value I coudnt generate. But it must be an easier way. Unfortunately the login step is not defined among the API operations.

Do you have experience consuming either the OpenSearch API or the OpenData API? How do you authenticate yourselves from a web environment before launching your queries?

Kind regards and thanks in advance

The documentation you attach specifies how to add username and password through cURL or Wget. If you are interested in consuming it from any other programming language you can take a look at HttpClient and Basic Authentication.

Finally, in principle you could use URL encoding, although it is/will be deprecated:

https://USERNAME:PASSWORD@scihub.copernicus.eu/apihub/search

Thanks for the response,

By attaching the Basic authentication header to the client, the login and product search operation can be combined into one unique request.

I paste below the code which worked for me (C#):

//Example of URL querying a rectangular polygon for a 24 hours time range:

string urlRest = https://scihub.copernicus.eu/apihub/search?rows=100&q=(%20footprint:"Intersects(POLYGON((-9.59619820367938%2035.15452608700588,-0.3155800031247396%2035.15452608700588,-0.3155800031247396%2037.171555713875236,-9.59619820367938%2037.171555713875236,-9.59619820367938%2035.15452608700588)))%22%20)%20AND%20(%20beginPosition:[2018-06-22T00:00:00.000Z%20TO%202018-06-23T23:59:59.999Z]%20AND%20endPosition:[2018-06-22T00:00:00.000Z%20TO%202018-06-23T23:59:59.999Z]%20)%20AND%20%20%20(platformname:Sentinel-1%20AND%20polarisationmode:VV+VH)

//Create authentication header:
AuthenticationHeaderValue authValue = new AuthenticationHeaderValue(“Basic”, Convert.ToBase64String(Encoding.ASCII.GetBytes($"{this.username}:{this.password}")));
HttpClient httpClient = new HttpClient(){
DefaultRequestHeaders = { Authorization = authValue }
};

//Launch the request:
HttpResponseMessage httpResponse = httpClient.GetAsync(new Uri(urlRest)).Result;