added a hack job of oauth2 for multiple accounts. you ONLY need a username in the .google/config file for each user section. requires console setup for each user's authentication file. directory structure: root@DC1:/custom/contact-sync# ls -la -R .: total 10828 drwxr-xr-x 3 root root 4096 Jun 4 21:24 . drwxr-xr-x 4 root root 4096 Jun 3 22:59 .. -rw-r--r-- 1 root root 36053 Jun 4 11:04 contacts-sync.py drwxr-xr-x 3 root root 4096 Jun 3 23:00 .google -rw-r--r-- 1 root root 1732 Jun 3 22:59 IYH-Google-Contact-Sync-279664c30d53.p12 ./.google: total 12 drwxr-xr-x 3 root root 4096 Jun 3 23:00 . drwxr-xr-x 3 root root 4096 Jun 4 21:24 .. drwxr-xr-x 2 root root 4096 Jun 4 10:55 authdata ./.google/authdata: total 72 drwxr-xr-x 2 root root 4096 Jun 4 10:55 . drwxr-xr-x 3 root root 4096 Jun 3 23:00 .. -rw------- 1 root root 859 Jun 4 08:02 accounting@sub.domain.tld.dat -rw------- 1 root root 859 Jun 4 08:02 user1@sub.domain.tld.dat -rw------- 1 root root 817 Jun 4 08:02 user2@sub.domain.tld.dat -rw------- 1 root root 859 Jun 4 08:02 user2@sub.domain.tld.dat -rw-r--r-- 1 root root 428 Jun 4 08:02 client_secret.apps.googleusercontent.com.json -rw------- 1 root root 817 Jun 4 08:02 dk@sub.domain.tld.dat -rw------- 1 root root 817 Jun 4 08:02 iy@sub.domain.tld.dat -rw------- 1 root root 817 Jun 4 08:02 ja@sub.domain.tld.dat -rw------- 1 root root 817 Jun 4 08:02 jt@sub.domain.tld.dat -rw------- 1 root root 859 Jun 4 08:02 jm@sub.domain.tld.dat -rw------- 1 root root 859 Jun 4 08:02 jo@sub.domain.tld.dat -rw------- 1 root root 817 Jun 4 08:02 ms@sub.domain.tld.dat -rw------- 1 root root 817 Jun 4 08:02 mn@sub.domain.tld.dat -rw------- 1 root root 859 Jun 4 08:02 nn@sub.domain.tld.dat -rw------- 1 root root 817 Jun 4 08:02 py@sub.domain.tld.dat -rw------- 1 root root 817 Jun 4 08:02 sb@sub.domain.tld.dat Update: to fix XML Issues, update line 525ish of /usr/local/lib/python2.7/dist-packages/atom/core.py change it from: tree = ElementTree.fromstring(xml_string) return _xml_element_from_tree(tree, target_class, version) to read as: xml_string = string.replace(xml_string, r'<gd:extendedProperty name="google_apps_sync">', '<gd:extendedProperty xmlns:gd="http://schemas.google_apps_sync.com/contact/2008" xmlns:ns3="http://schemas.google_apps_sync.com/contact/2008"$ tree = ElementTree.fromstring(xml_string) return _xml_element_from_tree(tree, target_class, version) adding the xml string line. (we're having to provide a google api with a reference to it's own xml namespace folks) Synchronize contacts across a set of GMail accounts. The accounts may be normal GMail accounts or in Google Apps. The script is tested for synchronizing two users and only marginally tested for three or more. Unlike most shared group synchronizers, this script synchronizes all group names and then all contacts except for contacts in groups named --private on the command line. This contacts-sync Python script depends on the Google Data APIs Python Client Library (https://code.google.com/p/gdata-python-client) which must be installed separately. IF YOU READ NOTHING ELSE: Pay particular attention to the way contacts are merged on the first run. Duplicate contacts across users will result in duplication everywhere. See the synchronize all contacts section below. Accounts and passwords are stored in ~/.google/config. See the sample/config file here for an example. The algorithm: - Synchronize all group names: - When first seen, groups are tagged with a unique identifier (UID). - Equivalent groups in each user's account have the same UID. - For new groups without a UID, look for a group of the same name in one of the other user's accounts. - If a group has been renamed by a user, propagate the name change to all groups sharing the UID. - Synchronize all contacts: - When first seen, contacts are tagged with a unique identifier (UID). - Newly seen contacts are replicated across all groups unless: They are not in any group or they are in a private group. NOTE: There is no effort made to match new contact names to give them a shared UID. Replication will cause each instance to be replicated everywhere. If you then use the Google tools to merge contacts in one account, the next synchronization will replicate the merge everywhere. Avoid this when adding a new account with the --addingnewaccount switch, which attempts to find equivalent names and assign existing UIDs to them. Differences in contact data for existing names may still cause problems. - Once tagged with a UID, contacts are linked by UID and not by name. Renaming a contact in one account will replicate properly to other users. - Modified contacts replace their corresponding entries in all other accounts. The script does not detect modification of the same entry in multiple accounts. One of the modified entries will be replicated and changes to the same contact in other accounts will be lost. - If a contact was replicated and has been newly added to a private group, replicated copies in other user's accounts are deleted. - If a replicated contact is deleted in one account it is deleted in all accounts.
RandySage/sync-google-contacts
Automatically exported from code.google.com/p/sync-google-contacts
Python