An object used to determine whether the user needs to authorize this script to use one or more services, and to provide the URL for an authorization dialog. If the script is published as an add-on that uses installable triggers, this information can be used to control access to sections of code for which the user lacks the necessary authorization. Alternately, the add-on can ask the user to open the URL for the authorization dialog to resolve the problem.
This object is returned by Script
. In almost
all cases, scripts should call Script
,
since no other authorization mode requires that users grant authorization.
Methods
Method | Return type | Brief description |
---|---|---|
get | Authorization | Gets a value that indicates whether the user needs to authorize this script to use one or more
services (for example, Script ). |
get | String | Gets the authorization URL that can be used to grant access to the script. |
Detailed documentation
getAuthorizationStatus()
Gets a value that indicates whether the user needs to authorize this script to use one or more
services (for example, Script
).
// Log the authorization status (REQUIRED or NOT_REQUIRED). const authInfo = ScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL); Logger.log(authInfo.getAuthorizationStatus());
Return
Authorization
— the authorization status
getAuthorizationUrl()
Gets the authorization URL that can be used to grant access to the script. This method returns
null
if no authorization is required. The page at the URL will close automatically if
it is accessed and the script does not require any authorization.
// Log the URL used to grant access to the script. const authInfo = ScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL); Logger.log(authInfo.getAuthorizationUrl());
Return
String
— a URL that can be used to authorize the script