lambdabaa / dav

WebDAV, CalDAV, and CardDAV client for nodejs and the browser.
Mozilla Public License 2.0
304 stars 71 forks source link

Contacts from iCloud are filtered out #114

Open ide opened 8 years ago

ide commented 8 years ago

I looked into using dav to interact with my iCloud contacts so that I could programmatically add contacts to my phone. One of the first things I ran into was that dav returns an empty list of address books because it filters out all address books missing a displayname field. When I remove that filter call, I get back all of my iCloud contacts.

I'm not familiar with DAV and don't know the right fix right now but maybe someone who has experience with DAV knows how to address this.

Code:

var dav = require('dav');
var util = require('util');

var xhr = new dav.transport.Basic(
  new dav.Credentials({
    username: 'xxx@gmail.com',
    password: 'hunter2',
  })
);

var client = new dav.Client(xhr);
client.createAccount({
  accountType: 'carddav',
  server: 'https://contacts.icloud.com',
  loadCollections: true,
  loadObjects: true,
}).then(account => {
  console.log(util.inspect(account.addressBooks, false, null));
}).catch(error => {
  console.error(error);
});
alexanderharm commented 6 years ago

@ide How exactly did you get this working? Using your example code I simply receive an empty array.

ide commented 6 years ago

IIRC the example code only reproduces the issue but it was from over a year ago.

alexanderharm commented 6 years ago

So you didn't manage to use this library to retrieve your contacts?

ide commented 6 years ago

From my original post it sounds like you could fork this library and get it working for this specific use case if that’s important. But I don’t think I used this library for my own project.

alexanderharm commented 6 years ago

Thanks.

Bramzor commented 5 years ago

Tested with removing the filter and it still returns an empty list of addressBooks, so seems that it fails somewhere else too.

adamchasetaylor commented 4 years ago

This works for me with iCloud `addressBooks = responses.filter(function (res) {

        //return typeof res.props.displayname === 'string';

        return res.props.resourcetype.includes('addressbook');

}`