MQL4 HELP - Include WinHTTP.dll for implementing authentication

 

Hi all,

I'm looking for a way to implement the basic HTTP authentication in MQL4 (an expert advisor, an indicator, whatever it is).

The idea would be to include the WinHTTP.dll library and use its methods to send an HTTP request for authentication. Unluckily I'm new in such "client-server" developments, so I would really appreciate if someone could help me. I've deeply searched in the CodeBase, but so far I was not able to find any article providing such kind of information.

Thanks a lot in advance to anyone will provide hints/information.

 
TradingGrep:

Hi all,

I'm looking for a way to implement the basic HTTP authentication in MQL4 (an expert advisor, an indicator, whatever it is).

The idea would be to include the WinHTTP.dll library and use its methods to send an HTTP request for authentication. Unluckily I'm new in such "client-server" developments, so I would really appreciate if someone could help me. I've deeply searched in the CodeBase, but so far I was not able to find any article providing such kind of information.

Thanks a lot in advance to anyone will provide hints/information.


Hmmm...not sure how deep that search was. You missed at least the following in the code base:

HTTP using WinINet directly in mql4

"Native" MQL HTTP Client

Also see Windows' WinINet API Reference and WinHTTP API Reference.

 

http basic authentication used to be widely achievable by simply using http://username:password@domain/..... in your URL.

Some browsers block this format due to phishing attacks but most APIs still allow it to be used.

Other than that IIRC you have to Base64 encode the "username:password" as an header in the HTTP request. (but sometimes only after a challenge from the server).

I'll update this post with some pointers once I dig them out ...


Here's one ... http://serverfault.com/questions/371907/can-you-pass-user-pass-for-http-basic-authentication-in-url-parameters

And another https://en.wikipedia.org/wiki/Basic_access_authentication#Client_side

 

more detail on the challenge if you get one:

if using an API, with some HTTP servers you will first get HTTP error code 401 (Not Authorized) first, and then you have to send the request again with the credentials. All browsers, and some APIS might hide this handshake sequence, and some APIs you'll have to do it yourself. I've never used the Windows APIs so not sure what they do.

PS OP I agree, there is only one mention of Http Basic Authentication in the code base and that was someone asking how to do it, and I couldn't see an answer.

 
ydrol:

http basic authentication used to be widely achievable by simply using http://username:password@domain/..... in your URL. [...]

(I'm guessing that the OP isn't asking about Basic authentication in HTTP. I think he/she is just asking about some method - any basic, simple one - of doing web requests from MQL4.)
 
gchrmt4:
(I'm guessing that the OP isn't asking about Basic authentication in HTTP. I think he/she is just asking about some method - any basic, simple one - of doing web requests from MQL4.)
hi, maybe but I think the word "authentication" in the subject is significant?
 
ydrol:
hi, maybe but I think the word "authentication" in the subject is significant?

Yes, the user authentication of: (expert advisor, an indicator, whatever it is) is supposed to happen remotely on a web server using the http protocol. It is how I understand OP.
 
gchrmt4:
(I'm guessing that the OP isn't asking about Basic authentication in HTTP. I think he/she is just asking about some method - any basic, simple one - of doing web requests from MQL4.)
Ovo:

Yes, the user authentication of: (expert advisor, an indicator, whatever it is) is supposed to happen remotely on a web server using the http protocol. It is how I understand OP.

I agree...I interpreted the OP as asking how to authenticate an EA or indicator using a web request. However, just in case my interpretation/assumption is incorrect and the OP is asking how to authenticate himself/herself to a remote web server, see "Authentication in WinHTTP".
 
Thirteen:

I agree...I interpreted the OP as asking how to authenticate an EA or indicator using a web request. However, just in case my interpretation/assumption is incorrect and the OP is asking how to authenticate himself/herself to a remote web server, see "Authentication in WinHTTP".
we'll have to wait for op to respond but their first two sentences seem to be clearly about http basic authentication to me.
 
Thirteen:

I agree...I interpreted the OP as asking how to authenticate an EA or indicator using a web request. .
I don't know what that means but I've. had 7 Bacardi :-)
 
ydrol:

http basic authentication used to be widely achievable by simply using http://username:password@domain/..... in your URL.

Some browsers block this format due to phishing attacks but most APIs still allow it to be used.

Other than that IIRC you have to Base64 encode the "username:password" as an header in the HTTP request. (but sometimes only after a challenge from the server).

I'll update this post with some pointers once I dig them out ...


http://username:password@domain/ is how I've always done this (and still do).

Though the Microsoft web site you shared clearly states it no longer works, I've had no problems using this method with IE 11.0.

I wish there was an example written in mql that would include Base64 encoding of the username and pass - since I really have no idea how to implement this method properly, and it would be better to do it correctly, since the older method of http://*:* could quit working completely amongst all popular browsers.

Nonetheless, this is a good thread and thank you both ydrol and Thirteen for the links you've provided.

Reason: