توضّح أدلة التشغيل السريع كيفية إعداد تطبيق وتشغيله، وهو تطبيق يستدعي إحدى واجهات Google Workspace API. يستخدم دليل البدء السريع هذا أسلوبًا مبسطًا للمصادقة مناسبًا لبيئة الاختبار. بالنسبة إلى بيئة الإنتاج، ننصحك بالتعرّف على
المصادقة والتفويض
قبل
اختيار بيانات اعتماد الوصول
المناسبة لتطبيقك.
في "برمجة التطبيقات"، تستخدم أدوات البدء السريع في Google Workspace خدمات Google المتقدّمة لاستدعاء واجهات برمجة التطبيقات في Google Workspace والتعامل مع بعض تفاصيل عملية المصادقة والتفويض.
الأهداف
ضبط البيئة
إنشاء النص البرمجي وإعداده
شغِّل النص البرمجي.
المتطلبات الأساسية
حساب Google تم تفعيل "مهام Google" فيه
الوصول إلى Google Drive
إنشاء النص البرمجي
أنشئ نصًا برمجيًا جديدًا في محرِّر "برمجة تطبيقات Google" من خلال الانتقال إلى script.google.com/create.
استبدِل محتوى أداة تعديل النصوص البرمجية بالرمز التالي:
/** * 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('No task lists found.');return;}for(consttaskListoftaskLists){console.log('%s (%s)',taskList.title,taskList.id);}}catch(err){// TODO (developer) - Handle exception from Task APIconsole.log('Failed with error %s',err.message);}}
انقر على "حفظ" .
انقر على مشروع بلا عنوان، واكتب البدء السريع، ثم انقر على إعادة تسمية.
ضبط النص البرمجي
تفعيل Google Tasks API
افتح مشروع Apps Script.
انقر على أداة التعديلcode.
بجانب الخدمات، انقر على "إضافة خدمة" add .
اختَر
Tasks API
وانقر على إضافة.
تشغيل العيّنة
في محرِّر Apps Script، انقر على تشغيل.
في المرة الأولى التي تُشغّل فيها النموذج، سيُطلب منك منح الإذن بالوصول:
تاريخ التعديل الأخير: 2025-09-04 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-09-04 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["Create a\n[Google Apps Script](/apps-script/overview)\nthat makes requests to the Google Tasks API.\n\nQuickstarts explain how to set up and run an app that calls a\nGoogle Workspace API. This quickstart uses a\nsimplified authentication approach that is appropriate for a testing\nenvironment. For a production environment, we recommend learning about\n[authentication and authorization](/workspace/guides/auth-overview)\nbefore\n[choosing the access credentials](/workspace/guides/create-credentials#choose_the_access_credential_that_is_right_for_you)\nthat are appropriate for your app.\n\nIn Apps Script, Google Workspace\nquickstarts use\n[Advanced Google services](/apps-script/guides/services/advanced) to call\nGoogle Workspace APIs and handle some details of the authentication\nand authorization flow.\n\nObjectives\n\n- Configure the environment.\n- Create and configure the script.\n- Run the script.\n\nPrerequisites\n\n\u003cbr /\u003e\n\n- A Google account with Google Tasks enabled.\n\n\u003cbr /\u003e\n\n- Access to Google Drive\n\nCreate the script\n\n1. Create a new script in the Apps Script editor by going to [script.google.com/create](https://script.google.com/create).\n2. Replace the contents of the script editor with the following code:\n\n\ntasks/quickstart/quickstart.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/tasks/quickstart/quickstart.gs) \n\n```javascript\n/**\n * Lists the user's tasks.\n * @see https://developers.google.com/tasks/reference/rest/v1/tasklists/list\n */\nfunction listTaskLists() {\n const optionalArgs = {\n maxResults: 10\n };\n try {\n // Returns all the authenticated user's task lists.\n const response = Tasks.Tasklists.list(optionalArgs);\n const taskLists = response.items;\n // Print task list of user if available.\n if (!taskLists || taskLists.length === 0) {\n console.log('No task lists found.');\n return;\n }\n for (const taskList of taskLists) {\n console.log('%s (%s)', taskList.title, taskList.id);\n }\n } catch (err) {\n // TODO (developer) - Handle exception from Task API\n console.log('Failed with error %s', err.message);\n }\n}\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n3. Click Save .\n4. Click **Untitled project** , type **Quickstart** , and click **Rename**.\n\n\u003cbr /\u003e\n\nConfigure the script\n\nEnable the Google Tasks API\n\nOpen the Apps Script project.\n\n1. Click **Editor** code.\n2. Next to **Services** , click Add a service add .\n3. Select Tasks API and click **Add**.\n\nRun the sample\n\nIn the Apps Script editor, click **Run**.\n\nThe first time you run the sample, it prompts you to authorize access:\n\n1. Click **Review permissions**.\n2. Choose an account.\n3. Click **Allow**.\n\nThe script's execution log appears at the bottom of the window. \ndone It worked! **Great!** Check out the further reading section below to learn more.\nwarning There was a problem **Bummer** , [let us know what went wrong](#). Check out our [troubleshooting](#troubleshooting) section below for some common errors and solutions. If you have found a bug in the code, [report the issue on GitHub](https://github.com/googleworkspace/apps-script-samples/issues) or submit a pull request.\n\nNext steps\n\n- [Google Apps Script Advanced Services documentation](/apps-script/guides/services/advanced)\n- [Try the Google Workspace APIs in the APIs explorer](/workspace/explore)\n- [Troubleshoot authentication and authorization issues](/workspace/tasks/troubleshoot-authentication-authorization)\n- [Tasks API reference documentation](/workspace/tasks/v1/reference)"]]