Google Apps Script 快速入門導覽課程
快速入門說明如何設定及執行呼叫 Google Workspace API 的應用程式。
Google Workspace 快速入門會使用 API 用戶端程式庫處理驗證和授權流程的部分細節。建議您為自家應用程式使用用戶端程式庫。本快速入門導覽課程會使用簡化的驗證方法,適合測試環境使用。如要使用正式環境,建議您先瞭解驗證和授權,再選擇適合應用程式的存取憑證。
建立向 Google Tasks API 提出要求的 Google Apps Script。
目標
必要條件
- 已啟用 Google Tasks 的 Google 帳戶。
建立指令碼
- 前往 script.google.com/create 建立新指令碼。
- 使用下列程式碼取代指令碼編輯器的內容:
- 按一下「儲存」圖示
。
- 按一下「無標題的專案」,輸入「Quickstart」,然後點選「Rename」。
啟用 Google Tasks API
- 開啟 Apps Script 專案。
- 按一下「編輯器」圖示 code。
- 按一下「服務」旁的「新增服務」圖示 add。
- 選取 Tasks API,然後按一下「新增」。
執行範例
在 Apps Script 編輯器中,按一下「Run」。
第一次執行範例時,系統會提示您授權存取權:
- 按一下「查看權限」。
- 選擇所需帳戶。
- 按一下「允許」。
指令碼的執行記錄會顯示在視窗底部。
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-12-21 (世界標準時間)。
[null,null,["上次更新時間:2024-12-21 (世界標準時間)。"],[[["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."]]],[]]