Google Apps List Shared Contacts

March 31, 2010    google apps Python

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.



comments powered by Disqus