Apps Script محدوده های مجوز (مانند دسترسی به فایل های Google Sheets یا Gmail) را به طور خودکار بر اساس اسکن کد تعیین می کند. کدی که نظر داده می شود همچنان می تواند یک درخواست مجوز ایجاد کند. اگر یک اسکریپت نیاز به مجوز داشته باشد، یکی از گفتگوهای مجوز را که در اینجا نشان داده شده است، هنگام اجرا می بینید.
اسکریپتهایی که قبلاً آنها را مجاز کردهاید، در صورتی که تغییر کد سرویسهای جدیدی اضافه میکند، درخواست مجوز اضافی میکنند. اگر به اسکریپت بهعنوان یک برنامه وب که تحت هویت کاربری مالک اسکریپت اجرا میشود، دسترسی داشته باشید، ممکن است اسکریپتها درخواست مجوز نکنند.
لغو حقوق دسترسی
برای لغو دسترسی اسکریپت به داده های خود، این مراحل را دنبال کنید:
از صفحه مجوزهای حساب Google خود دیدن کنید. (برای پیمایش به این صفحه در آینده، از Google.com بازدید کنید، سپس روی تصویر حساب خود در گوشه سمت راست بالای صفحه کلیک کنید. سپس روی حساب من ، سپس برنامهها و سایتهای متصل در بخش «ورود به سیستم و امنیت» و سپس مدیریت برنامهها کلیک کنید .)
روی نام اسکریپتی که میخواهید مجوز آن را لغو کنید کلیک کنید، سپس روی Remove در سمت راست کلیک کنید، سپس در گفتگوی بهدستآمده OK را بزنید .
مجوزها و انواع اسکریپت ها
هویت کاربری که یک اسکریپت با آن اجرا میشود - و بنابراین دادههایی که میتواند به آن دسترسی داشته باشد - بر اساس سناریویی که اسکریپت در آن اجرا میشود متفاوت است، همانطور که در جدول زیر نشان داده شده است.
دامنه مجوز دستی برای برگهها، اسناد، اسلایدها و فرمها
اگر در حال ساختن یک افزونه یا اسکریپت دیگری هستید که از سرویس صفحه گسترده ، سرویس سند ، سرویس اسلایدها ، یا سرویس فرم ها استفاده می کند، می توانید به جای همه صفحات گسترده، اسناد یا فرم های کاربر، کادر گفتگوی مجوز را مجبور کنید که فقط به فایل هایی که در آن برافزا یا اسکریپت استفاده شده است، بخواهید. برای انجام این کار، حاشیه نویسی JsDoc زیر را در یک نظر در سطح فایل قرار دهید:
/***@OnlyCurrentDoc*/
اگر اسکریپت شما دارای کتابخانه ای باشد که @OnlyCurrentDoc را اعلام می کند، یک حاشیه نویسی مخالف، @NotOnlyCurrentDoc ، در دسترس است، اما اسکریپت اصلی در واقع نیاز به دسترسی به بیش از فایل فعلی دارد.
چرخه عمر مجوز برای افزونه ها
افزونههای Google Sheets، Docs، Slides، و Forms معمولاً از همان مدل مجوز مانند اسکریپتهایی پیروی میکنند که به یک سند متصل میشوند. با این حال، در شرایط خاص، توابع onOpen(e) و onEdit(e) آنها در حالت بدون مجوز اجرا می شوند که برخی از عوارض اضافی را به همراه دارد. برای اطلاعات بیشتر، به راهنمای چرخه عمر مجوز افزونه ها مراجعه کنید.
محدودیت های کاربر برنامه OAuth
برنامههایی که از OAuth برای دسترسی به دادههای کاربر Google، از جمله پروژههای Apps Script استفاده میکنند، مشمول محدودیتهای مجوز هستند. برای جزئیات به محدودیت های کاربر برنامه OAuth مراجعه کنید.
رفتار احراز هویت مجدد با Apps Script
Apps Script فرکانس احراز هویت مجدد را که در تنظیمات Google Cloud Services پیکربندی میکنید، اعمال نمیکند. این به این دلیل است که Apps Script می تواند به طور خودکار با استفاده از تریگرها اجرا شود که بدون تعامل مستقیم کاربر عمل می کنند. این اجراهای خودکار، درخواستهای احراز هویت مجدد را راهاندازی نمیکنند. برنامه Apps Script شما پس از مدت زمانی که مشخص کرده اید (مثلاً 12 ساعت) به طور خودکار از شما درخواست احراز هویت مجدد نمی کند.
تاریخ آخرین بهروزرسانی 2025-08-19 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-08-19 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eApps Script requires user authorization to access private data from Google services, and requests are based on code analysis.\u003c/p\u003e\n"],["\u003cp\u003eUsers can revoke a script's access to their data through their Google Account permissions settings.\u003c/p\u003e\n"],["\u003cp\u003eA script's access level and the user it runs as depends on the type of script and how it's executed, like standalone, add-on, or web app.\u003c/p\u003e\n"],["\u003cp\u003eFor scripts interacting with Google Workspace files, specific annotations can limit authorization requests to the current file only.\u003c/p\u003e\n"],["\u003cp\u003eAdd-ons generally adhere to the authorization model of bound scripts, with exceptions for certain functions and circumstances.\u003c/p\u003e\n"]]],[],null,["Apps Script requires user authorization to access private data from\n[built-in Google services](/apps-script/guides/services) or\n[advanced Google services](/apps-script/guides/services/advanced).\n\nGranting access rights \n\nApps Script determines the authorization scopes (like access your Google Sheets\nfiles or Gmail) automatically, based on a scan of the code. Code that is\ncommented out can still generate an authorization request. If a script needs\nauthorization, you'll see one of the authorization dialogs shown here when it is\nrun.\n\nScripts that you have previously authorized also ask for additional\nauthorization if a code change adds new services. Scripts may not request\nauthorization if you access the script as a web app that runs under\n[the script owner's user identity](/apps-script/execution_web_apps#permissions).\n| **Warning:** Web apps and other scripts that use sensitive scopes are subject to review by Google. Users attempting to authorize such apps may see a warning screen saying the app is *unverified* by Google. See [OAuth client verification](/apps-script/guides/client-verification) for details.\n\nRevoking access rights\n\nTo revoke a script's access to your data, follow these steps:\n\n1. Visit the [permissions](https://security.google.com/settings/security/permissions) page for your Google account. (To navigate to this page in the future, visit [Google.com](https://www.google.com), then click your account picture in the top-right corner of the screen. Next, click **My Account** , then **Connected apps \\& sites** under the \"Sign-in \\& security\" section, and then **Manage Apps**.)\n2. Click the name of the script whose authorization you want to revoke, then click **Remove** on the right, then **OK** in the resulting dialog.\n\nPermissions and types of scripts\n\nThe user identity that a script runs with --- and thus the data it can access ---\nvaries based on the scenario in which the script is run, as shown in the table\nbelow.\n\n| Type of script | Script runs as... |\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Standalone](/apps-script/execution_script_editor), [add-on](/workspace/add-ons/overview), or [bound to Docs, Sheets, Slides, or Forms](/apps-script/guides/bound) | User at the keyboard |\n| [Custom function in a spreadsheet](/apps-script/execution_custom_functions) | [Anonymous user](/apps-script/execution_custom_functions#permissions); however, [quota limits](/apps-script/guides/services/quotas) count against user at the keyboard |\n| [Web app](/apps-script/execution_web_apps) or [Google Sites gadget](/apps-script/execution_gadgets) | User at the keyboard or script owner, dependent on [options selected](/apps-script/execution_web_apps#permissions) when deploying the app |\n| [Installable trigger](/apps-script/understanding_triggers#Installable) | User who created the trigger |\n\nManual authorization scopes for Sheets, Docs, Slides, and Forms\n\nIf you're building an [add-on](/workspace/add-ons/overview) or other script that\nuses the [Spreadsheet service](/apps-script/reference/spreadsheet),\n[Document service](/apps-script/reference/document),\n[Slides service](/apps-script/reference/slides), or\n[Forms service](/apps-script/reference/forms), you can force the authorization\ndialog to ask only for access to files in which the add-on or script is used,\nrather than all of a user's spreadsheets, documents, or forms. To do so, include\nthe following [JsDoc](https://jsdoc.app/) annotation in a file-level comment: \n\n /**\n * @OnlyCurrentDoc\n */\n\nAn opposing annotation, `@NotOnlyCurrentDoc`, is available if your script\nincludes a [library](/apps-script/guides/libraries) that declares\n`@OnlyCurrentDoc`, but the master script actually requires access to more than\nthe current file.\n\nAuthorization lifecycle for add-ons\n\n[Add-ons](/workspace/add-ons/overview) for Google Sheets, Docs, Slides, and Forms\ngenerally follow the same authorization model as scripts that are\n[bound](/apps-script/guides/bound) to a document. In certain\ncircumstances, however, their `onOpen(e)` and `onEdit(e)` functions run in a\nno-authorization mode that presents some additional complications. For more\ninformation, see the\n[guide to the add-ons authorization lifecycle](/workspace/add-ons/concepts/addon-authorization#editor_add-on_authorization).\n\nOAuth application user limits\n\nApplications that use OAuth to access Google user data, including Apps\nScript projects, are subject to authorization limits. See\n[OAuth application user limits](https://support.google.com/cloud/answer/9028764)\nfor details."]]