LoginSignup
2
2

More than 5 years have passed since last update.

Create a New Todoist Task from Python Script

Posted at

Background

At work, we just began to use (or experiment with) Todoist to keep track of log files we need to collect from sites. Todoist is a task management tool that is available on mobile, desktop and web platforms.

Motivation

I wanted to see if I can manipulate the tasks from scripts. I'm using yowsup to develop a Whatsapp bot so I was wondering if I can somehow get the bot to interact with the tasks (such as create new tasks, mark them as complete, etc). At a casual look, the script needs to use OAuth 2.0 token before it can interact with the tasks. Since I do not know anything about the OAuth 2.0 token, here's what I've done to get started.

Steps

Install pytodoist

pip install pytodoist

Get Google OAuth 2.0 Token

I don't know anything about OAuth 2.0 token. I definitely need to learn more about it later, but I found Google OAuth 2.0 Playground, where you can get a working token.

  1. Choose Google OAuth2 API v2
  2. Select https://www.googleapis.com/auth/userinfo.email and click Authorize APIs button
  3. Click Accept when Google OAuth 2.0 Playground requests to have offline access
  4. You will be given an authorization code. Click Exchange authorization code for tokens
  5. You will receive refresh and access tokens (If you do not see them, click Step 2 to reveal the tokens)
  6. Copy the access token

Login with Your OAuth 2.0 Token

from pytodoist import todoist
user = todoist.login_with_google('your-gmail-address', 'your-access-token')
print user.full_name
print user.is_logged_in()
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2