How to add authentificaion method to request?

ikod via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 11 12:06:16 PDT 2017


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);



More information about the Digitalmars-d-learn mailing list