authorization in WebRequest

 

Hi,

The exante platform has its own http api and I want to send an http request using the language mql4.

For example, in python, a simple request for the get method

requests.get(url = "https://api-demo.exante.eu/md/1.0/symbols/AAPL.NASDAQ", auth = ("<application id>: <access key>"))

I need to write this code in mql4,here with url arguments everything is clear, here is the problem with the auth argument, where should I write <application id>: <access key>

 
Sashaaa:

Hi,

The exante platform has its own http api and I want to send an http request using the language mql4.

For example, in python, a simple request for the get method

requests.get(url = "https://api-demo.exante.eu/md/1.0/symbols/AAPL.NASDAQ", auth = ("<application id>: <access key>"))

I need to write this code in mql4,here with url arguments everything is clear, here is the problem with the auth argument, where should I write <application id>: <access key>

do they state in their API that the application id should go in the request header ? (probably)

 
Lorentzos Roussos:

do they state in their API that the application id should go in the request header ? (probably)

They only say, that every request should be attributed with  Authorization header and bearer token issued for your API user and valid at the moment of request.

Basic http authentication is used with access key as password and application ID (not client ID) as username.

 
Sashaaa:

They only say, that every request should be attributed with  Authorization  header and bearer token issued for your API user and valid at the moment of request.

Basic http authentication is used with access key as password and application ID (not client ID) as username.

So you get your answer, you need to add a header with WebRequest, the credentials need to be Base64 encoded.

Basic access authentication - Wikipedia
  • en.wikipedia.org
In the context of an HTTP transaction, basic access authentication is a method for an HTTP user agent (e.g. a web browser) to provide a user name and password when making a request. In basic HTTP authentication, a request contains a header field in the form of , where credentials is the base64 encoding of id and password joined by a single...
 
Ален Верлейен:

Таким образом, вы получите свой ответ, вам нужно добавить заголовок с WebRequest, учетные данные должны быть в кодировке Base64.

Thanks, I write below code

but can't connect successfully. Where I made a mistake ?

   
   // <application id> = 1eab640c-8798-43b3-9fc2-f8deb990a62f
   // <access key> = lxXig0zIODcGncXeeeVn
   // To enable access to the server, I add URL "https://api-demo.exante.eu/md/1.0/symbols/AAPL.NASDAQ"

   int res;
   char post[], result[];
   string headers = "Login=1eab640c-8798-43b3-9fc2-f8deb990a62f&Password=lxXig0zIODcGncXeeeVn";

   res = WebRequest("GET", "https://api-demo.exante.eu/md/1.0/symbols/AAPL.NASDAQ", NULL, NULL, 0, post, 0, result, headers);
  
   Print(res); // show -1
 
Sashaaa:

Thanks, I write below code

but can't connect successfully. Where I made a mistake ?

The mistake is on the lack of  Base64 Encryption on the credentials