www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to add authentificaion method to request?

reply Suliman <evermind live.ru> writes:
I am using dlang-requests. I need authentificate on 
https://scihub.copernicus.eu/dhus/login and than do some 
data-parsing.

     MultipartForm form;
     form.add(formData("login_username", "Suliman"));
     form.add(formData("login_password", "123")); // changed
     auto content = 
postContent("https://scihub.copernicus.eu/dhus/login", form);
     writeln("Output:");
     writeln(content);

Return error about login pass. So it's seems that I need to add 
BasicAuthentication method type. But how to add it?


Browser console show next: https://snag.gy/VXaq2R.jpg
Jul 11
next sibling parent Cym13 <cpicard openmailbox.org> writes:
On Tuesday, 11 July 2017 at 12:15:39 UTC, Suliman wrote:
 I am using dlang-requests. I need authentificate on 
 https://scihub.copernicus.eu/dhus/login and than do some 
 data-parsing.

     MultipartForm form;
     form.add(formData("login_username", "Suliman"));
     form.add(formData("login_password", "123")); // changed
     auto content = 
 postContent("https://scihub.copernicus.eu/dhus/login", form);
     writeln("Output:");
     writeln(content);

 Return error about login pass. So it's seems that I need to add 
 BasicAuthentication method type. But how to add it?


 Browser console show next: https://snag.gy/VXaq2R.jpg
Something like: Request req; req.authenticator = new BasicAuthentication("login", "password");
Jul 11
prev sibling parent reply ikod <geller.garry gmail.com> writes:
On Tuesday, 11 July 2017 at 12:15:39 UTC, Suliman wrote:
 I am using dlang-requests. I need authentificate on 
 https://scihub.copernicus.eu/dhus/login and than do some 
 data-parsing.

     MultipartForm form;
     form.add(formData("login_username", "Suliman"));
     form.add(formData("login_password", "123")); // changed
     auto content = 
 postContent("https://scihub.copernicus.eu/dhus/login", form);
     writeln("Output:");
     writeln(content);

 Return error about login pass. So it's seems that I need to add 
 BasicAuthentication method type. But how to add it?


 Browser console show next: https://snag.gy/VXaq2R.jpg
Hello, Yo have to use Request object if you need to configure basic authentication. MultipartForm form; Request request; request.authenticator = new BasicAuthentication("user", "passwd"); form.add(formData("login_username", "Suliman")); form.add(formData("login_password", "123")); // changed auto response = request.post("https://scihub.copernicus.eu/dhus/login", form); auto content = response.responseBody; writeln("Output:"); writeln(content);
Jul 11
parent reply Suliman <evermind live.ru> writes:
Compiler require libssl32.dll for run dlang-request based app. 
Where I can get it?

I installed, OpenSSL, but can't find this lib in C:\OpenSSL-Win64
Jul 12
parent Cym13 <cpicard openmailbox.org> writes:
On Wednesday, 12 July 2017 at 07:43:27 UTC, Suliman wrote:
 Compiler require libssl32.dll for run dlang-request based app. 
 Where I can get it?

 I installed, OpenSSL, but can't find this lib in 
 C:\OpenSSL-Win64
I don't use windows so it's nothing definitive but I'd bet that the "32" in libssl32.dll stands for 32bits while OpenSSL-Win64 is for 64bits. You need to get the 32bits version.
Jul 12