如要在應用程式中使用 Apps Script API,請務必在應用程式的 GCP 專案中啟用 Apps Script API。啟用 Apps Script API 後,您就可以建立 OAuth 憑證,並下載用戶端 ID 和密鑰,以便納入應用程式。您也可以在 Google Cloud 控制台監控 API 用量。
您可以使用這個精靈,在 API 控制台中建立或選取 Google Cloud 專案,並自動啟用 API。或者,您也可以開啟控制台的「管理資源」頁面,選取專案,然後使用專案的「API 和服務」資訊主頁,手動搜尋並新增 Apps Script API。啟用 API 後,您可以在「API 和服務」>「憑證」面板中,為應用程式建立 OAuth 憑證、用戶端 ID 和用戶端密鑰。
[[["容易理解","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 (世界標準時間)。"],[[["\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."]]