หากต้องการใช้ Apps Script API ในแอปพลิเคชัน คุณต้องเปิดใช้ API ในโปรเจ็กต์ Google Cloud ของแอปพลิเคชัน
ซึ่งจะช่วยให้คุณสร้างข้อมูลเข้าสู่ระบบ OAuth เพื่อให้ผู้ใช้แอปพลิเคชัน
สามารถให้สิทธิ์ได้
หากต้องการใช้ Apps Script API ภายในแอป คุณต้องเปิดใช้
Apps Script API ในโปรเจ็กต์ GCP ของแอปพลิเคชัน หลังจาก
เปิดใช้ Apps Script API แล้ว คุณจะสร้างข้อมูลเข้าสู่ระบบ OAuth และดาวน์โหลด
รหัสไคลเอ็นต์และรหัสลับเพื่อรวมไว้ในแอปพลิเคชันได้ นอกจากนี้ คุณยังตรวจสอบการใช้งาน API ได้ในคอนโซล Google Cloud
คุณสามารถใช้วิซาร์ดนี้เพื่อสร้างหรือเลือกโปรเจ็กต์ Google Cloud ในคอนโซล API และเปิดใช้ API โดยอัตโนมัติ หรือคุณจะ
เปิดหน้าจัดการทรัพยากรของคอนโซล
เลือกโปรเจ็กต์ จากนั้นค้นหาและเพิ่ม Apps Script API ด้วยตนเองโดยใช้แดชบอร์ด API และบริการของโปรเจ็กต์ เมื่อเปิดใช้ API แล้ว คุณจะ
สร้างข้อมูลเข้าสู่ระบบ OAuth, รหัสไคลเอ็นต์ และข้อมูลลับไคลเอ็นต์สำหรับแอปพลิเคชัน
ในแผง API และบริการ > ข้อมูลเข้าสู่ระบบได้
Apps Script API สามารถอนุญาตให้แอปพลิเคชันสร้างและแก้ไขสคริปต์
และการทำให้ใช้งานได้ ซึ่งอาจทำให้เกิดสถานการณ์ที่ไม่ดีหากคุณให้สิทธิ์แอปพลิเคชันที่เป็นอันตรายของบุคคลที่สาม ซึ่งจากนั้นจะสร้างสคริปต์ที่เป็นอันตรายเพิ่มเติมหรือแก้ไขลักษณะการทำงานของสคริปต์ที่คุณมีอยู่แล้ว
Apps Script API จะเข้าถึงโปรเจ็กต์สคริปต์ไม่ได้โดยค่าเริ่มต้นเพื่อช่วยลดความเสี่ยงนี้ คุณต้องให้สิทธิ์เข้าถึง API อย่างชัดเจนก่อนจึงจะใช้แอปพลิเคชันใดๆ ที่สร้างหรือแก้ไขสคริปต์หรือการติดตั้งใช้งานได้
เมื่อให้สิทธิ์เข้าถึง API แก่สคริปต์แล้ว แอปพลิเคชันที่คุณให้สิทธิ์จะใช้ API เพื่อจัดการโปรเจ็กต์สคริปต์ได้
หากพยายามเรียกใช้แอปพลิเคชันที่ได้รับผลกระทบโดยไม่ให้สิทธิ์เข้าถึง API ก่อน ระบบจะแสดงข้อผิดพลาด ข้อผิดพลาดนี้เกิดขึ้นหลังจากที่คุณให้สิทธิ์แอปพลิเคชัน
คุณให้สิทธิ์เข้าถึง Apps Script API ในโปรเจ็กต์สคริปต์ได้โดยใช้
แดชบอร์ด Apps Script นอกจากนี้ คุณยัง
ใช้แดชบอร์ดเพื่อเพิกถอนสิทธิ์เข้าถึงนี้ได้ทุกเมื่อ เมื่อให้สิทธิ์เข้าถึง API คุณจะให้สิทธิ์สำหรับแอปพลิเคชันทั้งหมด อย่างไรก็ตาม คุณยังคงต้องให้สิทธิ์แอปพลิเคชันแต่ละรายการ
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-08-31 UTC"],[[["\u003cp\u003eThe Apps Script API requires enabling in your Google Cloud project to use it within your own application, allowing you to create OAuth credentials for user authorization.\u003c/p\u003e\n"],["\u003cp\u003eTo allow external applications to manage your script projects, you must grant access to them through the Apps Script dashboard, understanding the potential security risks involved.\u003c/p\u003e\n"],["\u003cp\u003eGranting access enables third-party applications to create, modify, and deploy your Apps Script projects but does not automatically authorize them; individual authorization is still required.\u003c/p\u003e\n"],["\u003cp\u003eExecuting Apps Script functions through the API does not necessitate granting access to your script projects.\u003c/p\u003e\n"]]],[],null,["# Enabling script authorization and access\n\nThe Apps Script API requires different types of authorizations depending on\nyour goal:\n\n- Use the Apps Script API in your app.\n- Allow other applications to manage your script project data or deployments.\n\nIf you need to use the Apps Script API in your application, you must *enable*\nthe API in the application's\n[Google Cloud project](https://cloud.google.com/apis/docs/enable-disable-apis#enable_an_api).\nThis allows you to create OAuth credentials so that users of the application\ncan authorize it.\n\nIf you want to let third-party applications manage the content or deployment\nof your script projects, you must *grant access* to your script projects.\n\nUsing the Apps Script API in your app\n-------------------------------------\n\nIf you want to use the Apps Script API inside your app, you must enable\nthe Apps Script API in your application's GCP project. After\nenabling the Apps Script API, you can create OAuth credentials and download\nthe client ID and secret to include in your application. You can also\nmonitor the API usage in the\n[Google Cloud console](https://console.cloud.google.com/).\n\nYou can use\n[this wizard](https://console.developers.google.com/start/api?id=script)\nto create or select a Google Cloud project in the API console and automatically enable\nthe API. Alternatively, you can\n[open the console's **Manage Resources** page](https://console.cloud.google.com/cloud-resource-manager),\nselect a project, then search for and add the Apps Script API manually using the\nproject's **APIs \\& services** dashboard. Once you've enabled the API, you can\ncreate OAuth credentials, client IDs, and client secrets for your applications\nin the **APIs \\& services \\\u003e Credentials** panel.\n\nThe [Apps Script API quickstarts](/apps-script/api/quickstart/python#step_1_turn_on_the_api_name)\nprovide a step-by-step look at the whole process of enabling the API and\nsetting up authorization for an application.\n\nGranting third-party applications access to your script projects\n----------------------------------------------------------------\n\nThe Apps Script API can allow applications to create and modify your scripts\nand their [deployments](/apps-script/concepts/deployments). This can lead to\na bad situation if you authorize a malicious third-party application which\nthen proceeds to create more malicious scripts or modify the behavior of\nscripts you already have.\n\nTo help reduce this risk, the Apps Script API cannot access your script\nprojects by default. You must explicitly grant the API access before you can use\nany application that creates or modifies scripts or deployments. Once you've\ngranted the API access to your scripts, applications you authorize can use the\nAPI to manage your script projects.\n\nAn error results if you attempt to run an affected application without\nfirst granting the API access. This error occurs after you authorize the\napplication.\n| **Note:** Applications can use the Apps Script API to [execute Apps Script functions](/apps-script/api/reference/rest/v1/scripts/run). These API requests do not require granting access to your script projects.\n\nYou can grant the Apps Script API access to your script projects using the\n[Apps Script dashboard](/apps-script/guides/dashboard#settings). You can also\nuse the dashboard to revoke this access at any time. When you grant the\nAPI access, you are doing so for *all* applications. Individual applications\nstill need to be authorized, however.\n\nBefore you grant access, be sure you understand that there is a risk involved\nin allowing applications to modify your scripts. Never authorize any application\nthat you suspect is malicious."]]