Panduan memulai menjelaskan cara menyiapkan dan menjalankan aplikasi yang memanggil Google Workspace API.
Panduan memulai Google Workspace menggunakan library klien API untuk menangani beberapa detail alur autentikasi dan otorisasi. Sebaiknya
gunakan library klien untuk aplikasi Anda sendiri. Panduan memulai ini menggunakan
pendekatan autentikasi sederhana yang sesuai untuk lingkungan
pengujian. Untuk lingkungan produksi, sebaiknya pelajari
autentikasi dan otorisasi
sebelum
memilih kredensial akses
yang sesuai untuk aplikasi Anda.
/** * 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);}}
Klik Simpan .
Klik Project tanpa judul, ketik Quickstart, lalu klik Rename.
Mengonfigurasi skrip
Mengaktifkan Google Tasks API
Buka project Apps Script.
Klik Editorcode.
Di samping Layanan, klik Tambahkan layanan
add .
Pilih Tasks API, lalu klik Tambahkan.
Menjalankan contoh
Di editor Apps Script, klik Run.
Saat pertama kali dijalankan, contoh aplikasi meminta Anda untuk mengotorisasi akses:
Klik Tinjau izin.
Pilih akun.
Klik Izinkan.
Log eksekusi skrip akan muncul di bagian bawah jendela.
[null,null,["Terakhir diperbarui pada 2024-12-21 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."]]],["This content details how to create and run a Google Apps Script that interacts with the Google Tasks API. Key actions include creating a new script, replacing the default code with a provided sample to list task lists, saving and renaming the script, and enabling the Tasks API within the script's services. Running the script requires authorizing access, after which it will display the user's task lists in the execution log, or error if failed. It use a simplified authorization and suggest to do more in depth authorization for production.\n"]]