Search code examples
icloudcaldav

icloud caldav returning 401 unauthorized


Was using caldav to access icloud calendar, it was working fine. Today, all the requests in my postman collection started to get 401 from caldav.icloud.com I am accessing my own personal account to test, double checked my password hundred times, still not working.

Request:

PROPFIND / HTTP/1.1
Host: caldav.icloud.com
Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/xml
Cache-Control: no-cache
Postman-Token: 39b27b44-0a6f-b351-540f-f9446df618d0

<propfind xmlns='DAV:'>
    <prop>
        <current-user-principal/>
    </prop>
</propfind>

Response was:

401 unauthorized 

Header:

Connection →keep-alive
Content-Length →141
Content-Type →text/html;charset=utf-8
Date →Fri, 30 Jun 2017 14:23:34 GMT
Server →AppleHttpServer/2f080fc0
Strict-Transport-Security →max-age=31536000; includeSubDomains
WWW-Authenticate →x-mobileme-authtoken realm="MMCalDav", basic realm="MMCalDav"
X-Apple-Request-UUID →95e3a459-10b1-4d0a-a3ae-73f29b569481
X-Responding-Server →caldav:44101701:pv38p41ic-ztdg01080801:8001:17D70:375f9f89bf
X-Transaction-Id →95e3a459-10b1-4d0a-a3ae-73f29b569481
access-control-expose-headers →X-Apple-Request-UUID, Via
via →icloudedge:br30p01ic-zteu01122201:7401:17D30:Berlin

Body:

<html>
    <head>
        <title>Unauthorized</title>
    </head>
    <body>
        <h1>Unauthorized</h1>
        <p>You are not authorized to access this resource.</p>
    </body>
</html>

Any ideas?


Solution

  • You cannot do a 3rd party login into iCloud with your regular login/password anymore (DAV, IMAP, etc). Since June 15, 2017 you need an "App specific password".

    This page describes how to generate one: Using app-specific passwords. From that page:

    • Sign in to your Apple ID account page.
    • In the Security section, click Generate Password below App-Specific Passwords.
    • Follow the steps on your screen.