تحدّد Apps Script نطاقات التفويض (مثل الوصول إلى ملفاتك في "جداول بيانات Google" أو Gmail) تلقائيًا، استنادًا إلى فحص الرمز. يمكن أن يؤدي الرمز البرمجي الذي تم التعليق عليه إلى إنشاء طلب تفويض. إذا كان البرنامج النصي يحتاج إلى تفويض، سيظهر لك أحد مربّعات حوار التفويض الموضّحة هنا عند تشغيله.
تطلب البرامج النصية التي سبق أن منحتها الإذن أيضًا الحصول على إذن إضافي إذا أدى تغيير الرمز إلى إضافة خدمات جديدة. قد لا تطلب النصوص البرمجية الحصول على إذن إذا تم الوصول إليها كتطبيق ويب يتم تشغيله ضمن هوية المستخدم لمالك النص البرمجي.
إبطال حقوق الوصول
لإبطال إذن وصول نص برمجي إلى بياناتك، اتّبِع الخطوات التالية:
انتقِل إلى صفحة الأذونات في حسابك على Google. (للانتقال إلى هذه الصفحة في المستقبل، انتقِل إلى Google.com، ثم انقر على صورة حسابك في أعلى يسار الشاشة. بعد ذلك، انقر على حسابي، ثم على التطبيقات والمواقع الإلكترونية المرتبطة ضمن قسم "تسجيل الدخول والأمان"، ثم على إدارة التطبيقات.
انقر على اسم البرنامج النصي الذي تريد إبطال تفويضه، ثم انقر على إزالة على اليسار، ثم على حسنًا في مربّع الحوار الناتج.
الأذونات وأنواع النصوص البرمجية
تختلف هوية المستخدم التي يتم تشغيل النص البرمجي بها، وبالتالي البيانات التي يمكنه الوصول إليها، حسب السيناريو الذي يتم فيه تشغيل النص البرمجي، كما هو موضّح في الجدول أدناه.
نطاقات التفويض اليدوي لخدمات "جداول بيانات Google" و"مستندات Google" و"العروض التقديمية من Google" و"نماذج Google"
إذا كنت بصدد إنشاء إضافة أو نص برمجي آخر يستخدم خدمة جداول البيانات أو خدمة المستندات أو خدمة العروض التقديمية أو خدمة النماذج، يمكنك فرض عرض مربّع حوار التفويض لطلب الوصول فقط إلى الملفات التي يتم استخدام الإضافة أو النص البرمجي فيها، بدلاً من جميع جداول البيانات أو المستندات أو النماذج الخاصة بالمستخدم. لإجراء ذلك، أدرِج التعليق التوضيحي التالي JsDoc في تعليق على مستوى الملف:
/***@OnlyCurrentDoc*/
يتوفّر تعليق توضيحي معاكس، @NotOnlyCurrentDoc، إذا كان النص البرمجي يتضمّن مكتبة تحدّد @OnlyCurrentDoc، ولكن النص البرمجي الرئيسي يتطلّب الوصول إلى أكثر من الملف الحالي.
مراحل ترخيص الإضافات
تتّبع الإضافات في "جداول بيانات Google" و"مستندات Google" و"العروض التقديمية من Google" و"نماذج Google" بشكل عام نموذج التفويض نفسه الذي تتّبعه البرامج النصية المرتبطة بمستند. ومع ذلك، في بعض الحالات، يتم تشغيل وظيفتَي onOpen(e) وonEdit(e) في وضع لا يتطلّب إذنًا، ما يؤدي إلى بعض التعقيدات الإضافية. لمزيد من المعلومات، يمكنك الاطّلاع على دليل دورة حياة تفويض الإضافات.
الحدود القصوى لعدد مستخدمي تطبيقات OAuth
تخضع التطبيقات التي تستخدم OAuth للوصول إلى بيانات مستخدمي Google، بما في ذلك مشاريع Apps Script، لحدود التفويض. راجِع مقالة
حدود المستخدمين في تطبيقات OAuth
للحصول على التفاصيل.
سلوك إعادة المصادقة باستخدام "برمجة تطبيقات Google"
لا تفرض Apps Script معدّل إعادة المصادقة الذي يتم إعداده في إعدادات "خدمات Google السحابية". ويرجع ذلك إلى أنّ
Apps Script يمكن تشغيله تلقائيًا باستخدام المشغّلات التي تعمل
بدون تفاعل مباشر من المستخدم. لا تؤدي عمليات التنفيذ المبرمَجة هذه إلى ظهور طلبات إعادة المصادقة. لن يطلب منك تطبيق Apps Script إعادة المصادقة تلقائيًا بعد الفترة الزمنية التي حدّدتها (على سبيل المثال، 12 ساعة).
تاريخ التعديل الأخير: 2025-08-31 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-08-31 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\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,["# Authorization for Google Services\n\nApps 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----------------------\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----------------------\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--------------------------------\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---------------------------------------------------------------\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\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-----------------------------\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.\n\nRe-authentication Behavior with Apps Script\n-------------------------------------------\n\nApps Script does not enforce the\n[re-authentication frequency](https://support.google.com/a/answer/9368756) that you\nconfigure in your Google Cloud Services settings. This is because\nApps Script can run automatically using triggers, which operate\nwithout direct user interaction. These automated executions don't trigger the\nre-authentication prompts. Your Apps Script application won't\nautomatically ask you to re-authenticate after the time period you've specified\n(for example, 12 hours)."]]