Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用delphirest客户端进行duoapi认证_Delphi - Fatal编程技术网

使用delphirest客户端进行duoapi认证

使用delphirest客户端进行duoapi认证,delphi,Delphi,我正在创建一个DelphiREST客户端来与DuoAPI交互。我可以在Postman中测试我的授权密钥和所有其他参数。但是,我无法在DelphiREST中复制相同的内容。我不确定我是否做错了。下面是我的示例代码: //aside from the parameters below //RESTClient1 baseurl is set to: https://api-sample123.duosecurity.com/ //RESTRequest1 Resource is set to thi

我正在创建一个DelphiREST客户端来与DuoAPI交互。我可以在Postman中测试我的授权密钥和所有其他参数。但是,我无法在DelphiREST中复制相同的内容。我不确定我是否做错了。下面是我的示例代码:

//aside from the parameters below
//RESTClient1 baseurl is set to: https://api-sample123.duosecurity.com/
//RESTRequest1 Resource is set to this standard resource: admin/v1/users

procedure TfrmMain.Button1Click(Sender: TObject);
    var
      sAuthorization, nDate, sUsername, sPassword : string;
    begin
    try   

      nDate := formatdatetime('ddd, d mmm yyyy hh:mm:ss', now()) + ' +1000';   

      sAuthorization := 'Basic justasamplekeyhere123:alsoatesthmacsha1hash';
      Restclient1.Params.Add();
      RESTClient1.Params[0].Name := 'Date';
      RESTClient1.Params[0].Value := nDate;
      Restclient1.Params[0].Options := [poDoNotEncode];
      Restclient1.Params.Add();
      RESTClient1.Params[1].Name := 'Authorization';
      RESTClient1.Params[1].Value := sAuthorization;
      Restclient1.Params[1].Options := [poDoNotEncode];
      Restclient1.ContentType := 'ctAPPLICATION_X_WWW_FORM_URLENCODED'; //application/x-www-form-urlencoded';

      RESTRequest1.Execute;  
      MEMO1.Lines.Add(RestRequest1.Response.Content);

    Except
      On E: Exception do
                begin
                   MessageDlg(E.Message, mtError, [mbOK], 0);
                end;
    end;

您能否向我们展示(可能是屏幕截图)您是如何在Postman中配置请求的,以查看从Postman到Delphi代码的转换中是否存在错误?别忘了把敏感信息删掉。我可以给你们介绍我在《邮递员》中使用的一个例子。这基本上就是我所拥有的,当然除了涉及到的密钥之外,我试图按照DUO API[link]()文档中的方法来设置参数,我猜在Postman参数中可能有base64编码@Peter Wolf您能告诉我们(可能是屏幕截图)您是如何在Postman中配置请求的,以查看从Postman到Delphi代码的转换中是否存在错误吗?别忘了把敏感信息删掉。我可以给你们介绍我在《邮递员》中使用的一个例子。这基本上就是我所拥有的,当然除了涉及到的密钥之外,我试图按照DUO API[link]()文档中的方法来设置参数,我猜在Postman参数中可能有base64编码@彼得·沃尔夫