如果您想在应用中使用 Apps Script API,则必须在应用的 GCP 项目中启用 Apps Script API。启用 Apps 脚本 API 后,您可以创建 OAuth 凭据并下载客户端 ID 和密钥,以包含在您的应用中。您还可以在 Google Cloud 控制台中监控 API 用量。
您可以使用此向导在 API 控制台中创建或选择 Google Cloud 项目,并自动启用 API。或者,您也可以打开控制台的“管理资源”页面,选择一个项目,然后使用该项目的 API 和服务信息中心手动搜索并添加 Apps 脚本 API。启用该 API 后,您可以在 API 和服务 > 凭据面板中为应用创建 OAuth 凭据、客户端 ID 和客户端密钥。
[null,null,["最后更新时间 (UTC):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."]]