最初にアカウントとパスワードで認証します ( http://developers.google.com/accounts/docs/AuthForInstalledAppsを参照)
auth=`curl --silent -d Email=whatever@gmail.com -d Passwd=yourpwd -d service=contacts https://www.google.com/accounts/ClientLogin|grep ^Auth=|cut -d= -f2`
謎の「tok」変数を入手。JSONリクエストの一部であることがわかりました:
tok=`curl --silent --header "Authorization: GoogleLogin auth=$auth" "https://www.google.com/s2/gastatus?out=js&rc=0" |sed 's/,/\n/g' |grep AuthToken |cut -d'"' -f6`
CSV をダウンロードします (Google 形式)。これは手動で行う方法とまったく同じです: support.google.com/mail/answer/24911?hl=en
curl -s --stderr - -L -o contacts-google-whatever\@gmail.com-$(date +%Y-%m-%d-%H.%M.%S).csv -H "Authorization:GoogleLogin auth=$auth" --insecure "https://www.google.com/s2/data/exportquery?ac=false&cr=true&ct=true&df=true&ev=true&f=g2&gids=6&gp=true&hl=en-US&id=personal&max=-1&nge=true&out=google_csv&sf=display&sgids=6%2Cd%2Ce%2Cf%2C17&st=0&tok=$tok&type=4"
変数「out」は、google_csv、outlook_csv、vcard のいずれかです。私のコードは bash です。curl コマンドを Python の同等のものに変更することをお勧めします。重要な情報は、変数と URL です。