Skip to content
Advertisement

calDAV “PROPFIND” call “401 Unauthorized” response from calendar.yahoo.com server

I am trying to send yahoo calendars(caldav) a request to get “current-user-principal” But In response I am getting “401 Unauthorized” error. Before this request I am making another request to get “OPTIONS” which is giving “200 OK” response.

Request call is



    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
    
    
        
            
        
    


Request Response is:



    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


I am using a client library which has a function to make server request



    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("rn",$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."rnrn".$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;
      }


Here is class init.



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


Link to library


The following request gives “200 ok” response which runs before above request:

Request to server



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


Response from server



    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


I also tried simplifying my password but that didn’t work either

Advertisement

Answer

I have found the Solution. I was using the conventional password in server call but in actual I had to use “APP Password” which you can create from your yahoo account Under “Account security” tab.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement