1

Delphi Seattle 10 で開発された ISAPI Webbroker アプリケーションがあります。これは、SSO Azure を使用したサインインをサポートしています。

TRest コンポーネントを使用して、アクセスコードとグラフ データを取得します。

ほとんどの場合は機能しますが、1日に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;

なぜこれが起こるのか、ウェブブローカアプリケーション内でこれを行うのは良い考えではありませんか?

4

0 に答える 0