Enum AuthMode
Stay organized with collections
Save and categorize content based on your preferences.
AuthMode
An enumeration that identifies which categories of authorized services Apps Script is able to
execute through a triggered function. These values are exposed in
triggered functions
as the
authMode
property of the
event parameter
,
e
. For
more information, see the
guide to the
authorization lifecycle for add-ons
.
To call an enum, you call its parent class, name, and property. For example,
ScriptApp.AuthMode.CUSTOM_FUNCTION
.
function onOpen(e) {
var 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).
var properties = PropertiesService.getDocumentProperties();
var 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();
}
Properties
Property
| Type
| Description
|
NONE
| Enum
| A mode that does not allow access to any services that require authorization. This mode occurs
when an add-on executes an
onOpen(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.
|
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.
|
LIMITED
| Enum
| A mode that allows access to a limited subset of services. This mode occurs when an add-on or a
script
bound
to a document executes an
onOpen(e)
or
onEdit(e)
simple trigger, except in the case described for
NONE
.
|
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
.
|
Except as otherwise noted, the content of this page is licensed under the
Creative Commons Attribution 4.0 License
, and code samples are licensed under the
Apache 2.0 License
. For details, see the
Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-11-01 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]