【问题标题】:goutte scraping with two factor authentication (duo)使用两因素身份验证进行 goutte 刮擦(二重奏)
【发布时间】:2017-10-12 10:07:24
【问题描述】:

我正在尝试让刮板在两因素身份验证 (Duo) 到位的情况下工作。每次我发送 POST 以尝试身份验证时,它都会失败并显示 400(错误请求)。这是我尝试过的最新版本的代码:

    use Goutte\Client;

    $client = new Client();

    $res = $client->request('POST', 'https://example.com/cosign.cgi', [
      'body' => 'login=theuser&password=thepassword&service=theservice&passcode=8675309',
  ]);

返回的错误页面正文表明需要启用 cookie。然而,在 $client 中启用了 cookie。

【问题讨论】:

    标签: php cookies guzzle goutte cosign-api


    【解决方案1】:

    "https://example.com/cosign.cgi" - 可能是 DSA (CoSign) API 之上的包装器。请揭示背后的代码。关于如何在登录时使用 2 因素身份验证:有关 DSA API 的完整信息,请参阅 DSA Programmer GuideDSA Developer Center。 DSA v8.2+ 中引入了 RESTFull API。这是一个例子:

    <?php
    $request = new HttpRequest();
    $request->setUrl('https://cosign:8081/sapiws/v1/digital_signature');
    $request->setMethod(HTTP_METH_PUT);
    $request->setHeaders(array('postman-token' => 'c37705a2-4e8a-eb47-fcbe-62568507717b',
                               'cache-control' => 'no-cache',
                               'content-type' => 'application/json',
                               'authorization' => 'Basic YXZpdjoxMjM0NTY3OEFi'));
    $request->setBody('{ "signField" :  {"file":"BASE64PDFContent",
                                         "FileType": "PDF",
                                         "signPassword": "password",
                                         "signPasswordType": "STRING"
                                        }
                       }');
    try {
          $response = $request->send();
          echo $response->getBody();
       } 
       catch (HttpException $ex) {
       echo $ex;
    }
    

    在基本授权标头中插入密码以登录 DSA 签名者帐户。在正文“signPassword”字段中插入 OTP。

    用您正确公开的设备 DNS 替换 https://cosign:8081/sapiws/v1/digital_signature 中的 cosign 占位符。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-30
      • 2015-12-08
      • 2021-10-03
      • 2020-05-29
      • 2016-06-18
      • 1970-01-01
      • 2019-07-21
      • 1970-01-01
      相关资源
      最近更新 更多