Google Apps List Shared Contacts

I’ll be the first to call out Google that their gdata python library for connecting into the Google Apps API is the worst.

I wanted to grab all the shared contacts from our domain and it was a giant in the ass. Here is the code I ended up with


import gdata.contacts.client

contact_list = gdata.contacts.client.ContactsClient()
contact_list.client_login(email="user@domain.com",
                                password="password",
                                source='comany-app-1',
                                account_type='HOSTED')
feed_url = contact_list.GetFeedUri(contact_list="domain.com", projection='full')

while True:
    feed = contact_list.get_feed(
                                uri=feed_url,
                                auth_token=None,
                                desired_class=gdata.contacts.data.ContactsFeed)

    for entry in feed.entry:
        print entry.title.text

    next_link = feed.GetNextLink()
    if next_link is None:
        break

    feed_url = next_link.href

The email you use needs to have admin rights over your domain in Google Apps.

About mike
Currently works for OpenSky as a Senior Linux Admin. He has a wonderful wife Thanuja and 2 great dogs. His major side project is Photoblog.

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!