Enum AuthMode
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
حالت احراز هویت شمارشی که مشخص میکند کدام دسته از سرویسهای مجاز Apps Script میتواند از طریق یک تابع راهاندازی شده اجرا شود. این مقادیر در توابع راه اندازی شده به عنوان ویژگی auth Mode
پارامتر رویداد ، e
. برای اطلاعات بیشتر، راهنمای چرخه عمر مجوز برای افزونهها را ببینید.
برای فراخوانی یک enum، کلاس والد، نام و ویژگی آن را فراخوانی می کنید. به عنوان مثال، ScriptApp.AuthMode.CUSTOM_FUNCTION
.
function onOpen(e) {
const menu = SpreadsheetApp.getUi().createAddonMenu();
if (e && e.authMode === ScriptApp.AuthMode.NONE) {
// Add a normal menu item (works in all authorization modes).
menu.addItem('Start workflow', 'startWorkflow');
} else {
// Add a menu item based on properties (doesn't work in AuthMode.NONE).
const properties = PropertiesService.getDocumentProperties();
const workflowStarted = properties.getProperty('workflowStarted');
if (workflowStarted) {
menu.addItem('Check workflow status', 'checkWorkflow');
} else {
menu.addItem('Start workflow', 'startWorkflow');
}
// Record analytics.
UrlFetchApp.fetch('http://www.example.com/analytics?event=open');
}
menu.addToUi();
}
خواص
اموال | تایپ کنید | توضیحات |
---|
NONE | Enum | حالتی که اجازه دسترسی به خدماتی که نیاز به مجوز دارند را نمی دهد. این حالت زمانی اتفاق میافتد که یک افزونه یک راهانداز ساده on Open(e) اجرا میکند، و کاربر افزونهای را در سند دیگری نصب کرده است، اما این افزونه در سند فعلی استفاده نشده است. |
CUSTOM_FUNCTION | Enum | حالتی که امکان دسترسی به زیرمجموعه محدودی از خدمات را برای استفاده در عملکردهای صفحه گسترده سفارشی فراهم می کند. برخی از این سرویسها - از جمله دسترسی فقط خواندنی به سرویس صفحهگسترده - معمولاً به مجوز نیاز دارند، اما وقتی در یک عملکرد سفارشی استفاده میشوند، بدون مجوز مجاز هستند. از آنجایی که توابع سفارشی شامل پارامتر رویداد نیستند، این مقدار هرگز برگردانده نمی شود. فقط برای نشان دادن اینکه توابع سفارشی در حالت مجوز خودشان اجرا می شوند مستند شده است. |
LIMITED | Enum | حالتی که امکان دسترسی به زیرمجموعه محدودی از خدمات را فراهم می کند. این حالت زمانی اتفاق میافتد که یک افزونه یا یک اسکریپت متصل به یک سند، یک راهانداز ساده را on Open(e) یا on Edit(e) اجرا میکند، به جز در موردی که برای NONE توضیح داده شده است. |
FULL | Enum | حالتی که امکان دسترسی به تمام خدماتی که نیاز به مجوز دارند را می دهد. این حالت زمانی رخ میدهد که یک افزونه یا یک اسکریپت در نتیجه هر راهاندازی غیر از مواردی که برای LIMITED یا NONE توضیح داده شده است، اجرا میشود. |
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eAuthMode defines the level of access Apps Script has to authorized services when a triggered function is executed.\u003c/p\u003e\n"],["\u003cp\u003eIt's crucial for understanding how add-ons and scripts interact with Google services, especially concerning user authorization.\u003c/p\u003e\n"],["\u003cp\u003eDifferent AuthModes like NONE, LIMITED, and FULL, dictate the scope of service access, impacting functionalities within triggered functions.\u003c/p\u003e\n"],["\u003cp\u003eCustom functions operate under a specific authorization mode that allows restricted access to certain services without explicit user authorization.\u003c/p\u003e\n"]]],[],null,["# Enum AuthMode\n\nAuthMode\n\nAn enumeration that identifies which categories of authorized services Apps Script is able to\nexecute through a triggered function. These values are exposed in [triggered functions](/apps-script/understanding_triggers) as the `auth``Mode`\nproperty of the [event parameter](/apps-script/understanding_events), `e`. For\nmore information, see the [guide to the\nauthorization lifecycle for add-ons](/gsuite/add-ons/concepts/addon-authorization#authorization_modes).\n\nTo call an enum, you call its parent class, name, and property. For example, `\nScriptApp.AuthMode.CUSTOM_FUNCTION`.\n\n```javascript\nfunction onOpen(e) {\n const menu = SpreadsheetApp.getUi().createAddonMenu();\n if (e && e.authMode === ScriptApp.AuthMode.NONE) {\n // Add a normal menu item (works in all authorization modes).\n menu.addItem('Start workflow', 'startWorkflow');\n } else {\n // Add a menu item based on properties (doesn't work in AuthMode.NONE).\n const properties = PropertiesService.getDocumentProperties();\n const workflowStarted = properties.getProperty('workflowStarted');\n if (workflowStarted) {\n menu.addItem('Check workflow status', 'checkWorkflow');\n } else {\n menu.addItem('Start workflow', 'startWorkflow');\n }\n // Record analytics.\n UrlFetchApp.fetch('http://www.example.com/analytics?event=open');\n }\n menu.addToUi();\n}\n``` \n\n### Properties\n\n| Property | Type | Description |\n|-------------------|--------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `NONE` | `Enum` | A mode that does not allow access to any services that require authorization. This mode occurs when an add-on executes an `on``Open(e)` simple trigger, and the user has installed an add-on in a different document but the add-on has not been used in the current document. |\n| `CUSTOM_FUNCTION` | `Enum` | A mode that allows access to a limited subset of services for use in custom spreadsheet functions. Some of these services --- including read-only access to Spreadsheet service --- normally require authorization, but are permitted without authorization when used in a custom function. Because custom functions do not include an event parameter, this value is never returned; it is documented only to demonstrate that custom functions run in their own authorization mode. |\n| `LIMITED` | `Enum` | A mode that allows access to a limited subset of services. This mode occurs when an add-on or a script [bound](/apps-script/scripts_containers) to a document executes an `on``Open(e)` or `on``Edit(e)` simple trigger, except in the case described for `NONE`. |\n| `FULL` | `Enum` | A mode that allows access to all services that require authorization. This mode occurs when an add-on or a script executes as the result of any trigger other than the cases described for `LIMITED` or `NONE`. |"]]