Delphi Seattle 10 WebStker ISAPI dll

时间:2015-10-16 10:00:55

标签: delphi azure delphi-10-seattle webbroker

我们在Delphi Seattle 10中开发了一个ISAPI webbroker应用程序。 它支持使用SSO Azure登录。

我们使用TRest组件来获取访问代码和图形数据。

它的大部分工作时间,但每天1或2次,它给我们这个错误:

REST请求失败:打开请求时出错:(6)句柄无效

设置是:我们在datammodule中有3个休息组件

     RESTClientsso: TRESTClient;
     RESTRequestsso: TRESTRequest;
     RESTResponseSSO: TRESTResponse;

我们将Rest组件分配给一个类

AzureSSOClass:=TAzureSSOClass.Create;
try
  AzureSSOClass.RESTClientSSO:=RESTClientsso;
  AzureSSOClass.RESTRequesTSSO:=RESTRequestsso;
  AzureSSOClass.RESTResponseSSO:=RESTResponseSSO;    

然后我们有了这个提供警报的功能 的 RESTRequestSSO.Execute;

function TAzureSSOClass.getAccessCode: Boolean;
var

  LJSONObject : TJSONObject;
  infoRest : String;
  s:String;
begin
 result :=true;

 s:='https://login.microsoftonline.com/';
 s:=s+FTenant+'/oauth2/token';
 RESTClientSSO.BaseURL:=s;

 RESTClientSSO.HandleRedirects:=true;
 RESTRequestSSO.Method :=TRESTRequestMethod.rmPOST;

 // paramter..
 RestRequestSSO.Params.Clear;
 RestRequestSSO.Params.AddItem('grant_type', 'authorization_code');
 RestRequestSSO.Params.AddItem('code',   Fcode);
 RestRequestSSO.Params.AddItem('client_id', FClientID);
 RestRequestSSO.Params.AddItem('resource', 'https://graph.windows.net');
 RestRequestSSO.Params.AddItem('client_secret',FClientSecret);

 RESTRequestSSO.Execute;  // here we get the error

  inforest:=RESTResponseSSO.Content;
   try
      LJSONObject := TJSONObject.ParseJSONValue(TEncoding.ASCII.GetBytes(infoRest), 0) as TJSONObject;
      FAccessCode:=LJSONObject.Values['access_token'].Value;
      Fidtoken:=LJSONObject.Values['access_token'].Value;
      GetPayload;
      ParseToken;
   finally
    LJSONObject.Free
   end;

  if FAccessCode =''  then
  begin
   Ferror:='error getting access code';
   result:=false;
  end;

end;

知道为什么会这样,在webbroker应用程序中执行此操作不是一个好主意吗?

0 个答案:

没有答案