Skip to main content

Google Calendar Backup utility.

Project description

This package provides an simpler interface to Google calendars using the google-api-python-client python package and OAuth.

Examples

Note: See the “Setting up the project on Google” section below before trying the examples.

List calendar names:

>>> from gback import GCalSession
>>> session = GCalSession('~/gback.oauth')
>>>
>>> for c in session.names: print c

Add an appointment to a named calendar:

>>> from gback import GCalSession

>>> # print the output will display the appiointment url.
>>> # 'Marc' is the name of the calendar used.

>>> session = GCalSession('~/gback.oauth')
>>> des='Write a simpler way to use the google calendar api.'
>>> print session['Marc'].add('Write Python code.', '20150430', des=des)

Create an ical file for all the appointments in the named calendar:

>>> from gback import GCalSession

>>> cal_name = 'Marc'
>>> session = GCalSession('~/gback.oauth')
>>> with open(cal_name + '.ical'), 'w') as fh:
>>>   fh.write(session[cal_name].events)

Setting up the project on Google

Visit:

https://console.developers.google.com/project/

Choose “Create Project” Enter a project name. This can be anything. I used “gback” for google backup. Read the agreements and agree to them if you wish to continue. Wait while Activities windows works on setting up your project. Select “APIs & auth” on the left pane to expand menu items. select “Credentials” select “Create new Client ID” select “Installed application”

Answer consent screen information prompt.

Select your email address and enter your project name in the “Product Name” field. I entered “gback”.

Click on “Save”

If prompted to create another client id. Click on “Cancel”.

You have to repeat the following steps. But this time “gback” should be shown in the drop down box at the top of the web page.

select “Create new Client ID” select “Installed application” select “Other” for the installed application type.

Now you should have a “Client ID for native application shown”. Select “Download JSON”

That will save a JSON file with a client_id and client_secret among other things. It will have a long file name but you can rename it to anything you like, “gback.json”, say.

Enable APIs:

Under “APIs & auth” select “APIs” Select “Google+ API” Then enable it.

Under “APIs & auth” select “APIs” Select “Calendar API” Then enable it.

The first time you run this program it will launch your browser to log into your Google account. It will get a key and save it to your named OAuth file using the –oauthfn arg. After that it will read your OAuth file to get the key.

$ python gback.py -l –clientfn gback.json –oauthfn gback.oauth

After logging in using on your browser click on ‘Accept’ when prompted that gcalcback would ike to “Manage your calendars”.

From now on the gback.py program should work using the gback.json and gback.oauth files without need for a browser.

Note:

Running this program requested permission which needed validation using a browser which did not work with w3m because it doesn’t support Javascript. I had to run it the first time on ny in xwindows so it could launch chrome for validation. It stored keys etc using Storage() to a file so that it doesn’t need to revalidate again.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gback-0.52.tar.gz (6.3 kB view details)

Uploaded Source

File details

Details for the file gback-0.52.tar.gz.

File metadata

  • Download URL: gback-0.52.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for gback-0.52.tar.gz
Algorithm Hash digest
SHA256 8824b8167a5491e41350cdb4e2e7177d22315db022a196e1934d69d118ebda68
MD5 998089e60d7bd1491f2fdfee7a63002d
BLAKE2b-256 2f8fcecbeaa1a0bebaae441935cd191ffe0e1f3c310d54b6a7ff744341e33179

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page