【问题标题】:calDAV "PROPFIND" call "401 Unauthorized" response from calendar.yahoo.com servercalDAV“PROPFIND”调用来自 calendar.yahoo.com 服务器的“401 Unauthorized”响应
【发布时间】:2021-02-19 04:41:28
【问题描述】:

我正在尝试向 yahoo calendars(caldav) 发送获取“当前用户主体”的请求,但作为响应,我收到“401 Unauthorized”错误。在此请求之前,我正在发出另一个请求以获取“OPTIONS”,该请求给出“200 OK”响应。

请求调用是

PROPFIND / HTTP/1.1 Authorization: Basic XXXXXXXXXXXXXXXX= Host: calendar.yahoo.com:443 Depth: 0 Prefer: return-minimal Content-type: application/xml; charset=utf-8 Content-Length: 85 User-Agent: DAViCalClient Connection: close

请求响应是:

string(613) "HTTP/1.1 401 Unauthorized WSHost: tardis012.cal.bf1.yahoo.com Set-Cookie: rememberMe=deleteMe; Path=/; Max-Age=0; Expires=Thu, 18-Feb-2021 03:44:03 GMT WWW-Authenticate: Basic realm="YahooCalendar" WWW-Authenticate: OAuth realm="YahooCalendar" Content-Length: 0 Date: Fri, 19 Feb 2021 03:44:03 GMT Age: 1 Server: ATS Referrer-Policy: no-referrer-when-downgrade Connection: close Strict-Transport-Security: max-age=15552000 Expect-CT: max-age=31536000, report-uri="http://csp.yahoo.com/beacon/csp?src=yahoocom-expect-ct-report-only" X-XSS-Protection: 1; mode=block X-Content-Type-Options: nosniff

我正在使用一个客户端库,它具有发出服务器请求的功能

function DoRequest( $relative_url = "" ) { if(!defined("_FSOCK_TIMEOUT")){ define("_FSOCK_TIMEOUT", 10); } $headers = array(); $headers[] = $this->requestMethod." ". $this->base_url . $relative_url . " HTTP/1.1"; $headers[] = "Authorization: Basic ".base64_encode($this->user .":". $this->pass ); $headers[] = "Host: ".$this->server .":".$this->port; foreach( $this->headers as $ii => $head ) { $headers[] = $head; } $headers[] = "Content-Length: " . strlen($this->body); $headers[] = "User-Agent: " . $this->user_agent; $headers[] = 'Connection: close'; $this->httpRequest = join("\r\n",$headers); $this->xmlRequest = $this->body; $fip = fsockopen( $this->protocol . '://' . $this->server, $this->port, $errno, $errstr, _FSOCK_TIMEOUT); //error handling? if ( !(get_resource_type($fip) == 'stream') ) return false; if ( !fwrite($fip, $this->httpRequest."\r\n\r\n".$this->body) ) { fclose($fip); return false; } $rsp = ""; while( !feof($fip) ) { $rsp .= fgets($fip,8192); } fclose($fip); $this->headers = array(); // reset the headers array for our next request $this->ParseResponse($rsp); return $rsp; }

这是类初始化。

$cal = new CalDAVClient("https://calendar.yahoo.com/", "piyush138", "XXXXXXXXXXX", "calendar" );

Link to library


以下请求给出“200 ok”响应,在上述请求之前运行:

请求服务器

OPTIONS / HTTP/1.1 Authorization: Basic cGl5dXNoMTM4OkQxZzF0YWxoZWw= Host: calendar.yahoo.com:443 Content-Length: 0 User-Agent: DAViCalClient Connection: close

来自服务器的响应

string(668) "HTTP/1.1 200 OK WSHost: tardis030.cal.bf1.yahoo.com Set-Cookie: rememberMe=deleteMe; Path=/; Max-Age=0; Expires=Thu, 18-Feb-2021 03:44:01 GMT DAV: 1, 3, calendar-access MS-Author-Via: DAV Allow: HEAD, MKCOL, POST, PROPFIND, ACL, COPY, REPORT, OPTIONS, PUT, DELETE, MKCALENDAR, MOVE, GET, PROPPATCH Content-Length: 0 Date: Fri, 19 Feb 2021 03:44:02 GMT Age: 3 Server: ATS Referrer-Policy: no-referrer-when-downgrade Connection: close Strict-Transport-Security: max-age=15552000 Expect-CT: max-age=31536000, report-uri="http://csp.yahoo.com/beacon/csp?src=yahoocom-expect-ct-report-only" X-XSS-Protection: 1; mode=block X-Content-Type-Options: nosniff

我也尝试过简化密码,但也没有用

【问题讨论】:

    标签: php caldav


    【解决方案1】:

    我找到了解决方案。 我在服务器调用中使用了常规密码,但实际上我必须使用您可以从中创建的“APP密码” 您的雅虎帐户在“帐户安全”选项卡下。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-26
      相关资源
      最近更新 更多