gpt4 book ai didi

web-services - 使用带有身份验证的 Web 服务总是给出消息 Authentication required

转载 作者:行者123 更新时间:2023-12-03 15:34:15 26 4
gpt4 key购买 nike

我尝试在 Delphi 2010 中使用消费一个 Web 服务。此 Web 服务位于端口 8000 上并进行身份验证。

我实现了

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;

但我仍然收到消息“需要身份验证”。

我做错了什么吗?

最佳答案

对于基本身份验证,这应该有效:

Basic Authentication in Delphi 7 SOAP

this post 中所述,较新版本的 Delphi 也允许使用

HTTPRio.HTTPWebNode.UserName := Username;
HTTPRio.HTTPWebNode.Password := Password;

关于web-services - 使用带有身份验证的 Web 服务总是给出消息 Authentication required,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4459637/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com