Using a web service with authentication always gives a message Authentication Required

I am trying to use one web service since Delphi 2010. This web service is on port 8000 with authentication.

I am implementing

function TForm4.EncodeLoginPW(const ALogin, APW: string): string;
begin
  Result := EncdDecd.EncodeString(ALogin + ':' + APW); // EncdDecd is not documented in 
end;


procedure TForm4.HTTPRIO1HTTPWebNode1BeforePost(const HTTPReqResp: THTTPReqResp;
  Data: Pointer);
var
  s: string;
begin
  s := 'Authorization: Basic ' + EncodeLoginPW(UserName, Password);
  if not HttpAddRequestHeaders(Data, PChar(s), Length(s), HTTP_ADDREQ_FLAG_ADD) then
    ShowMessage('HttpAddRequestHeaders' + SysErrorMessage(GetLastError()));
end;

but I have the message "Authentication Required".

Am I doing something wrong?

+3
source share
2 answers

For basic authentication, this should work:

Basic SOAP Authentication for Delphi 7

As explained in this post , newer versions of Delphi also allow you to use

HTTPRio.HTTPWebNode.UserName := Username;
HTTPRio.HTTPWebNode.Password := Password;
+2
source

- , (.Net Java) HTTP- (Fiddler Don Proxy) (WireShark), .

0

Source: https://habr.com/ru/post/1780644/


All Articles