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
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.
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.)
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.
(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.)
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".
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".
I agree...I interpreted the OP as asking how to authenticate an EA or indicator using a web request. .
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.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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.