Stay organized with collections
Save and categorize content based on your preferences.
Quickstarts explain how to set up and run an app that calls a
Google Workspace API.
Google Workspace quickstarts use the API client libraries to handle some
details of the authentication and authorization flow. We recommend that
you use the client libraries for your own apps. This quickstart uses a
simplified authentication approach that is appropriate for a testing
environment. For a production environment, we recommend learning about
authentication and authorization
before
choosing the access credentials
that are appropriate for your app.
Create a
Google Apps Script
that makes requests to the Google Tasks API.
/** * Lists the user's tasks. * @see https://developers.google.com/tasks/reference/rest/v1/tasklists/list */functionlistTaskLists(){constoptionalArgs={maxResults:10};try{// Returns all the authenticated user's task lists.constresponse=Tasks.Tasklists.list(optionalArgs);consttaskLists=response.items;// Print task list of user if available.if(!taskLists||taskLists.length===0){console.log('Notasklistsfound.');return;}for(consttaskListoftaskLists){console.log('%s(%s)',taskList.title,taskList.id);}}catch(err){// TODO (developer) - Handle exception from Task APIconsole.log('Failedwitherror%s',err.message);}}
Click Save .
Click Untitled project, type
Quickstart, and click Rename.
Configure the script
Enable the Google Tasks API
Open the Apps Script project.
Click Editorcode.
Next to Services, click Add a service
add .
Select
Tasks API
and click Add.
Run the sample
In the Apps Script editor, click Run.
The first time you run the sample, it prompts you to authorize access:
Click Review permissions.
Choose an account.
Click Allow.
The script's execution log appears at the bottom of the window.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-19 UTC."],[[["This quickstart demonstrates how to create a Google Apps Script that interacts with the Google Tasks API to list tasks."],["Before running the script, you need a Google account with Google Tasks and Drive enabled, and you will need to enable the Google Tasks API within the script."],["The script utilizes Google API client libraries for authentication and is designed for a testing environment; production environments require more robust authentication."],["After configuring and running the script, it will prompt for authorization to access your Google Tasks data and then display your task lists in the execution log."],["For more advanced usage and troubleshooting, refer to the provided links for Google Apps Script, authentication, and the Tasks API."]]],[]]