在我的客户端应用程序中,我使用以下代码在 header 中添加 token :
RESTRequest.Params.AddItem('Authorization', 'Bearer ' + MyToken, TRESTRequestParameterKind.pkHTTPHEADER, [TRESTRequestParameterOption.poDoNotEncode]);
我想使用 datasnap 在我的服务器中获取此 token 。
可能吗?
我该怎么做?
编辑
我可以验证 Datasnap
执行 TIdCustomHTTPServer.DoParseAuthentication
并且 DoParseAuthentication
调用 FOnParseAuthentication
(如果已分配)。
那么,我如何破解 Datasnap 来分配我自己的 OnParseAuthentication
?
我认为这解决了我的问题。
最佳答案
我也有同样的问题。如果使用 Authentication header ,那么我们会收到 EIdHTTPUnsupportedAuthorizationScheme 错误,我需要设置 OnParseAuthentication。我今天才开始研究这个问题,在测试应用程序“桌面”中我可以执行以下操作。
procedure TMainForm.FormCreate(Sender: TObject);
begin
FServer := TIdHTTPWebBrokerBridge.Create(Self);
FServer.OnParseAuthentication := DoParseAuthentication;// <-added this line
end;
现在我需要弄清楚如何更新 ASAPI dll 来执行相同的操作。
关于delphi - 如何使用 datasnap 获取作为 header 传递的 token ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35036638/