Sync google contacts by group to a limited number of users

153 Views Asked by At

I am trying to build an open-source python code hosted at GAE to sync contacts by group to a limited number of users. In a web interface users will be able to pick their group and whom it will be synced with.

I understand there is a lot of applications on market place withe the same functionality, but my organization is concerned about those provides selling contacts to 3rd parties. We are a non-profit organization, so the code could be hosted at google project or github for community contribution.

(sorry for the long intro)

  • How is the best way to start? is there tutorial available with similar functionality that I can expand?
  • What is the best way to compare two Contact kind elements? To see if they need to be sync.
  • Is there a last update on the Contact kind elements? In case I want to implement a last update wins?

thanks!

2

There are 2 best solutions below

0
On

I don't know of any tutorials for syncing and comparing contacts specifically, but there is a getting started guide for the Google Contacts API at https://developers.google.com/google-apps/contacts/v3/.

The contacts are sent as XML blobs, so you could compare two contacts by parsing them and looking at the individual elements within them. I don't think there's a better way to do this but there are libraries to handle it for you.

There is a last updated field sent as part of the contacts when retrieving them with the API. It is an XML element labeled <updated>.

2
On
how are you getting different user's contacts feeds?

i tried to save the tokens in the datastore when the
users grant the access, but when i get the token back
from datastore for 2 users at a time, after an hour
when the token expires, 
all tokens start working like the current users token
and i can only get current users contacts.

token = Get_Shared_User_Token(user_email)
contact_client = gdata.contacts.client.ContactsClient(source=USER_AGENT)
authorized_client = token.authorize(contact_client)

contacts_feed = authorized_client.GetContacts(q = query)

can you please tell how one can get any user's contacts?