사용자가 스크립트의 필수 범위에 대한 승인을 부여했는지 확인하는 객체입니다. 또한 객체는 사용자가 이러한 권한을 부여할 수 있는 승인 URL을 제공합니다.
일부 스크립트 실행은 스크립트에서 사용하는 모든 필수 범위에 대한 사용자의 동의 없이 시작될 수 있습니다. 이 객체의 정보를 사용하면 특정 범위가 필요한 코드 섹션에 대한 액세스를 제어하고 후속 실행을 위해 이러한 범위의 승인을 요청할 수 있습니다.
이 객체는 ScriptApp.getAuthorizationInfo(authMode)에 의해 반환됩니다. 다른 승인 모드에서는 사용자가 승인을 부여해야 하므로 거의 모든 경우 스크립트는 ScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL)를 호출해야 합니다.
사용자가 하나 이상의 서비스를 사용하도록 이 스크립트를 승인해야 하는지 여부를 나타내는 값을 가져옵니다 (예: ScriptApp.AuthorizationStatus.REQUIRED).
// Log the authorization status (REQUIRED or NOT_REQUIRED).constauthInfo=ScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL);Logger.log(authInfo.getAuthorizationStatus());
스크립트에 대한 액세스 권한을 부여하는 데 사용할 수 있는 승인 URL을 가져옵니다. 이 메서드는 승인이 필요하지 않으면 null를 반환합니다. URL의 페이지에 액세스하고 스크립트에 승인이 필요하지 않으면 페이지가 자동으로 닫힙니다.
// Log the URL used to grant access to the script.constauthInfo=ScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL);Logger.log(authInfo.getAuthorizationUrl());
리턴
String: 스크립트를 승인하는 데 사용할 수 있는 URL입니다.
getAuthorizedScopes()
스크립트에 승인된 범위 목록을 가져옵니다. 지정된 범위 목록에 대한 승인 정보가 요청되면 지정된 목록에서 승인된 범위를 반환합니다.
// 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());
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 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."]]