Skip to main content

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.

Release files for gback 0.52

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gback 0.52
File Size Uploaded
gback-0.52.tar.gz 6.3 kB Details

Release files / gback-0.52.tar.gz

Download URL gback-0.52.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8824b8167a5491e41350cdb4e2e7177d22315db022a196e1934d69d118ebda68
BLAKE2b-256 checksum
How to use checksums
2f8fcecbeaa1a0bebaae441935cd191ffe0e1f3c310d54b6a7ff744341e33179
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.52 This release

1 release file

0.51

1 release file

0.5

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page