I needed to backup my Google Drive documents to my NAS at home and while i was at it i also used this stuff to export my calendar to a nice plain-text list for later scripting. So if anyone is interested this is how i did it on my mac to get all events from my calendar to a nice formatted list to create your own todo-list or motd message when open your terminal or whatever you like to do!
Get the needed files, assumed you have python already installed on your machine:
wget http://gdata-python-client.googlecode.com/files/gdata-2.0.14.tar.gz wget http://googlecl.googlecode.com/files/googlecl-0.9.13.tar.gz
Unpack and install:
tar -zxvf gdata-2.0.14.tar.gz && cd gdata-2.0.14 && sudo python setup.py install tar -zxvf googlecl-0.9.13.tar.gz && cd googlecl-0.9.13 && sudo python setup.py install
Locate where google-cli ended up, on my mac:
/opt/local/Library/Frameworks/Python.framework/Versions/2.5/bin/google (On my linux box it ended up in /usr/local/bin/)
Create symlink or copy to /usr/local/bin/ (or add to PATH)
Next, make a test run, you’ll need to authenticate first time and allow your computer to access the calendar (or tasks, drive etc etc):
cn-macbook-w:~ christian$google calendar today
follow the instructions to authenticate and create tokens (very easy!) On osx the default browser pops up and wants you to authenticate, if no x-server it will print out a http-url you need to copy-paste in a browser and allow your computer to access the info.
run it again:
cn-macbook-w:~ christian$google calendar today [email@example.com] testing,Oct 20 11:00 - Oct 20 12:00
Sweet, now i want to get the whole month of october as a list:
cn-macbook-w:~ christian$ google calendar list --date 2013-04-01,2013-04-30 --fields title,when,where Admin,Oct 29 00:00 - Oct 30 00:00,Home Massage,Oct 29 17:30 - Oct 29 18:30,Stockholm
… ETC …