Johan Euphrosine
June 2011
Updated January 2013 by Danny Hermes
This article shows how to build a simple Python App Engine application that retrieves a list of tasks with the Google Tasks API. Google Tasks stores tasks that users enter via GMail, their mobile device, or calendar. The Google Tasks API provides developers with a powerful set of API endpoints for searching, reading, and updating Google Tasks content and metadata.
During this tutorial you will learn how to:
- Create a simple App Engine app using the Google APIs Client Library for Python.
- Provide Google Tasks users a mechanism to authorize your app to access their tasks.
- Make authorized requests to the Google Tasks API.
The source code for the final step of this tutorial is available in Google APIs Client Library for Python samples directory .
Before You Start
- Install Google App Engine SDK for Python for local testing and deployment of your application.
- Install Mercurial to check out a repository.
- Get the Google APIs Client Library for Python . This library supports the Google Tasks API.
Step 1: Create Your App Engine Project
First, you need to create a web application:
-
Create a new directory named
mytasks
. This will contain your new application. -
In the
mytasks
directory, create a file namedapp.yaml
with the following contents:application: mytasks version: 1 runtime: python27 api_version: 1 threadsafe: true handlers: - url: .* script: main.application
For more information, see Python Application Configuration .
-
In the
mytasks
directory, create a file namedmain.py
with the following contents:import webapp2 class MainHandler(webapp2.RequestHandler): def get(self): self.response.write('Hello App Engine!') application = webapp2.WSGIApplication([('/', MainHandler)], debug=True)
-
Run
dev_appserver.py app.yaml
. -
Point your browser to http://localhost:8080 .
-
You will see
Hello App Engine!
in the browser window.
Step 2: Enabling Your Application for the Tasks API
Next, you need to enable your application to use the Tasks API. The following
instructions take you through the process for an app named
mytasks
:
To get started using Tasks API, you need to first create or select a project in the Google Developers Console and enable the API . Using this link guides you through the process and activates the Tasks API automatically.
Alternatively, you can activate the Tasks API yourself in the Developers Console by doing the following:
- Go to the Google Developers Console .
- Select a project, or create a new one.
- In the sidebar on the left, expand APIs & auth . Next, click APIs . In the list of APIs, make sure the status is ON for the Tasks API.
- In the sidebar on the left, select Credentials .
In either case, you end up on the Credentials page and can create your project's credentials from here.
If you haven't done so already, create your OAuth 2.0 credentials by clicking Create new Client ID under the OAuth heading. Next, look for your application's client ID and client secret in the relevant table. You may also create and edit redirect URIs from this page.
Record your
client ID
and
client secret
from the
Google Developers Console
.