Problems with iCloud Calendar

117 views
Skip to first unread message

Stefan Kauerauf

unread,
Nov 7, 2013, 7:05:49 AM11/7/13
to cald...@googlegroups.com
Hello,

I am trying to connect to my iCloud Account with caldav4j.
I've set up the client and can connect and (probably) authenticate but the MkCalendarMethod response is 403-Forbidden.
as Host i use the pXX-caldav.icloud.com with https and as path for the method i use /XXXXXX/calendars/home/ (All the X are numbers according to my account)

HttpClient client = new HttpClient();

        HostConfiguration hostConfig = new HostConfiguration();
        Credentials credentials = new UsernamePasswordCredentials("my-ac...@address.de", "password");
        hostConfig.setHost("caldav.icloud.com", 443, "https");
        //hostConfig.setHost(new URI("https://caldav.icloud.com:443/XXXXXXX/calendars/home/"));

        AuthScope authScope = new AuthScope("caldav.icloud.com", 443);
        client.getState().setCredentials(authScope, credentials);
        client.setHostConfiguration(hostConfig);
        List authPrefs = new ArrayList(1);
        authPrefs.add(AuthPolicy.BASIC);
        client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
        Object param = client.getParams().getParameter(AuthPolicy.AUTH_SCHEME_PRIORITY);
        
        CalDAV4JMethodFactory factory = new CalDAV4JMethodFactory();
        MkCalendarMethod mk = factory.createMkCalendarMethod();

        mk.setPath("/XXXXXXX/calendars/home/");
        int httpsResponse = client.executeMethod(mk);

        for (Header h : mk.getResponseHeaders()) {
            System.out.println("HEADER: " + h.getName());
            for (HeaderElement e : h.getElements()) {
                System.out.println("  ELEMENT: " + e.getName());
                try {
                    for (NameValuePair p : e.getParameters()) {
                        System.out.println("    PARAM: " + p.getName() + " - " + p.getValue());
                    }
                } catch (NullPointerException ex) {
                    
                }

            }
            
        }
        
        System.out.println("BODY: " + mk.getResponseBodyAsString());
            System.out.println("RESPONSECODE: " + httpsResponse);

Has anyone got caldav4j  working with iCloud?

Roberto Polli

unread,
Nov 7, 2013, 9:51:33 AM11/7/13
to cald...@googlegroups.com
Why are you creating your own HttpClient instead of using the Caldav4j one?
Did you try to run the unittests with your calendar server?

Peace,
R.

2013/11/7 Stefan Kauerauf <ma...@stefankauerauf.de>:
> --
> You received this message because you are subscribed to the Google Groups
> "caldav4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to caldav4j+u...@googlegroups.com.
> To post to this group, send email to cald...@googlegroups.com.
> Visit this group at http://groups.google.com/group/caldav4j.
> For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages