Mit Sammlungen den Überblick behalten Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Autorisierungsinformationen
Ein Objekt, das prüft, ob der Nutzer die Autorisierung für die erforderlichen Bereiche des Scripts erteilt hat. Das Objekt enthält auch eine Autorisierungs-URL, über die Nutzer diese Berechtigungen gewähren können.
Einige Scriptausführungen können gestartet werden, ohne dass der Nutzer seine Einwilligung für alle erforderlichen Bereiche erteilt hat, die vom Script verwendet werden. Mit den Informationen in diesem Objekt können Sie den Zugriff auf Codeabschnitte steuern, für die bestimmte Bereiche erforderlich sind, und die Autorisierung dieser Bereiche für nachfolgende Ausführungen anfordern.
Dieses Objekt wird von ScriptApp.getAuthorizationInfo(authMode) zurückgegeben. In fast allen Fällen sollten Scripts ScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL) aufrufen, da bei keinem anderen Autorisierungsmodus Nutzer die Autorisierung erteilen müssen.
Gibt einen Wert zurück, der angibt, ob der Nutzer dieses Script für die Verwendung eines oder mehrerer Dienste autorisieren muss (z. B. ScriptApp.AuthorizationStatus.REQUIRED).
Ruft eine Liste der autorisierten Bereiche für das Script ab.
Detaillierte Dokumentation
getAuthorizationStatus()
Gibt einen Wert zurück, der angibt, ob der Nutzer dieses Script für die Verwendung eines oder mehrerer Dienste autorisieren muss (z. B. ScriptApp.AuthorizationStatus.REQUIRED).
// Log the authorization status (REQUIRED or NOT_REQUIRED).constauthInfo=ScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL);Logger.log(authInfo.getAuthorizationStatus());
Ruft die Autorisierungs-URL ab, mit der Zugriff auf das Script gewährt werden kann. Diese Methode gibt null zurück, wenn keine Autorisierung erforderlich ist. Die Seite mit der URL wird automatisch geschlossen, wenn darauf zugegriffen wird und das Script keine Autorisierung erfordert.
// Log the URL used to grant access to the script.constauthInfo=ScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL);Logger.log(authInfo.getAuthorizationUrl());
Rückflug
String: eine URL, mit der das Script autorisiert werden kann
getAuthorizedScopes()
Ruft eine Liste der autorisierten Bereiche für das Script ab. Wenn Autorisierungsinformationen für eine bestimmte Liste von Bereichen angefordert werden, werden die autorisierten Bereiche aus der angegebenen Liste zurückgegeben.
// Logs which scopes in the specified list have been authorized for the script.constauthInfo=ScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL,['https: //www.googleapis.com/auth/documents','https: //www.googleapis.com/auth/spreadsheets',]);Logger.log(authInfo.getAuthorizedScopes());
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-07-26 (UTC)."],[[["\u003cp\u003eAuthorizationInfo is an object used to determine if a user needs to authorize a script to use services and provides the authorization dialog URL.\u003c/p\u003e\n"],["\u003cp\u003eThis object is primarily used in add-ons with installable triggers to manage user access or prompt for authorization.\u003c/p\u003e\n"],["\u003cp\u003eIt offers two methods: \u003ccode\u003egetAuthorizationStatus()\u003c/code\u003e to check if authorization is required, and \u003ccode\u003egetAuthorizationUrl()\u003c/code\u003e to obtain the authorization URL.\u003c/p\u003e\n"],["\u003cp\u003eScripts should generally use \u003ccode\u003eScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL)\u003c/code\u003e for comprehensive authorization checks.\u003c/p\u003e\n"]]],[],null,["AuthorizationInfo\n\nAn object that checks if the user has granted authorization for the required scopes of the\nscript. The object also provides an authorization URL for users to grant those permissions.\n\nSome script executions can start without a user's consent to all required scopes used by the\nscript. The information in this object lets you control access to sections of code that require\ncertain scopes and request authorization of those scopes for subsequent executions.\n\nThis object is returned by [ScriptApp.getAuthorizationInfo(authMode)](/apps-script/reference/script/script-app#getAuthorizationInfo(AuthMode)). In almost\nall cases, scripts should call `Script``App.getAuthorizationInfo(ScriptApp.AuthMode.FULL)`,\nsince no other authorization mode requires that users grant authorization. \n\nMethods\n\n| Method | Return type | Brief description |\n|-------------------------------------------------------|---------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [getAuthorizationStatus()](#getAuthorizationStatus()) | [AuthorizationStatus](/apps-script/reference/script/authorization-status) | Gets a value that indicates whether the user needs to authorize this script to use one or more services (for example, `Script``App.AuthorizationStatus.REQUIRED`). |\n| [getAuthorizationUrl()](#getAuthorizationUrl()) | `String` | Gets the authorization URL that can be used to grant access to the script. |\n| [getAuthorizedScopes()](#getAuthorizedScopes()) | `String[]` | Gets a list of authorized scopes for the script. |\n\nDetailed documentation \n\n`get``Authorization``Status()` \nGets a value that indicates whether the user needs to authorize this script to use one or more\nservices (for example, `Script``App.AuthorizationStatus.REQUIRED`).\n\n```javascript\n// Log the authorization status (REQUIRED or NOT_REQUIRED).\nconst authInfo = ScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL);\nLogger.log(authInfo.getAuthorizationStatus());\n```\n\nReturn\n\n\n[AuthorizationStatus](/apps-script/reference/script/authorization-status) --- the authorization status\n\n*** ** * ** ***\n\n`get``Authorization``Url()` \nGets the authorization URL that can be used to grant access to the script. This method returns\n`null` if no authorization is required. The page at the URL will close automatically if\nit is accessed and the script does not require any authorization.\n\n```javascript\n// Log the URL used to grant access to the script.\nconst authInfo = ScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL);\nLogger.log(authInfo.getAuthorizationUrl());\n```\n\nReturn\n\n\n`String` --- a URL that can be used to authorize the script\n\n*** ** * ** ***\n\n`get``Authorized``Scopes()` \nGets a list of authorized scopes for the script. If authorization information is requested for\na specified list of scopes, returns the authorized scopes from the specified list.\n\n```javascript\n// Logs which scopes in the specified list have been authorized for the script.\nconst authInfo = ScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL, [\n 'https: //www.googleapis.com/auth/documents',\n 'https: //www.googleapis.com/auth/spreadsheets',\n]);\nLogger.log(authInfo.getAuthorizedScopes());\n```\n\nReturn\n\n\n`String[]` --- The list of authorized scopes."]]