401 Mit Indy IdHttp-Digest-Authentifizierung in Delphi XE

Versuchen zu tun, ein get() mit Digest-zu einem partner-web service mit Delphi XE.

Ich habe IdAuthenticationDigest zu der uses-Klausel, die automatisch arbeiten, von dem, was ich gelesen habe - aber ich muss etwas fehlen, da bin ich immer einen 401-Unauthorized.

Code:

begin
  // Init request:   
  IdHttp := TIdHttp.Create(nil);
  try
    idHttp.Request.ContentType := self.inputType; // 'application/xml'
    idHttp.Request.Accept := self.outputType; //'application/json';

    // Set request method:
    idHttp.Request.Method := Method; // 'Get'
    // Set username and password:
    idHttp.Request.BasicAuthentication := False;
    // IdHttp.Request.Username/Password also fails
    IdHttp.Request.Authentication.Username := 'xx';
    IdHttp.Request.Authentication.password := 'xx';

    IdHttp.Request.ContentLength := Length(Body);

    // Send request:
    if Method = 'GET' then
      Result := idHttp.Get(self.ServiceHost + URI)
    else
    if Method = 'POST' then
      Result := idHttp.Post(self.ServiceHost + URI, SendStream);

   finally
    idHttp.Free;
   end;
end;
Schreibe einen Kommentar