Hello, I have a problem that I'm concerned about: how to set a password for Google Sheet. Besides setting permissions with the "Share" button, is there any solution for sheets with passwords? Thanks.
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com .
To view this discussion visit https://groups.google.com/d/msgid/google-apps-script-community/af6482b6-0297-424e-8c8b-62330cc68c15n%40googlegroups.com .
To view this discussion visit https://groups.google.com/d/msgid/google-apps-script-community/CAHNYQLhaoNhC5Ep5fXzQ_AKGB9sZFEuoOBbi%3D8NB5AtOvLxT%2BA%40mail.gmail.com .

To view this discussion visit https://groups.google.com/d/msgid/google-apps-script-community/b2a04284-a7da-45a4-877d-761f2b83e73bn%40googlegroups.com .
To view this discussion visit https://groups.google.com/d/msgid/google-apps-script-community/768377fb-9f03-4913-9173-ffe0d48cf2a9n%40googlegroups.com .
To view this discussion visit https://groups.google.com/d/msgid/google-apps-script-community/e036001e-c190-4087-9ee6-c949ef20a0f2n%40googlegroups.com .
To view this discussion visit https://groups.google.com/d/msgid/google-apps-script-community/CAHNYQLg%3DPBihQJ6YmAdRBXeFQh9naBe%3DgYiWHqfjKd-u%2BtMnmA%40mail.gmail.com .
This report provides a technical analysis of a user request posted in the Google Apps Script Community , based on the content extracted from Gmail-Apps-Script-Password-for-Sheet.pdf.
The user (Robert Lee) asked:
“How can I set a password on a Google Sheet, besides the native sharing permissions, so that anyone with the link can access, but only those who know the password can edit?”
This document evaluates:
The technical limitationsof Google Sheets and Apps Script for implementing “password protection”.
The risksof creating a script-based password layer.
Secure, realistic alternativesto achieve the user's goal.
From the PDF:
Asks if it is possible to set a password on a Google Sheet beyond native sharing.
Requests more details and explains that:
sharing permissions
sheet/range protectionare the only existing ways to restrict access.
He wants:
a login-like pageasking for a password before editing;
“anyone with the link” should be able to access;
Apps Script should enforce the password.
Public access via link.
Ability to edit only afterentering a password.
Avoid manually managing sharing permissions for each editor.
Reasonable security.
Simple user experience.
Maintainable and not easily breakable.
Google Sheets access is governed onlyby:
Drive file sharing permissions.
Google Account authentication.
Apps Script cannot overrideor add new authentication layers to the document.
No “pre-access password” mechanism
Apps Script triggers ( onOpen
) only run after
the user already has access.
Permissions override scriptsIf shared with edit rights, the user can:
Remove the script,
Copy the file,
Export the file,
Delete protected ranges.
Scripts are visible to editorsAny editor can open Apps Script and read or remove the validation logic.
Public editing and password control are incompatible
When a file is set to “Anyone with the link can edit,” Apps Script cannot restrict editing.
A password implemented via Apps Script cannot provide real security.
It can only create a visual barrier
, not actual protection.
If you try to enforce a password inside the Sheet:
Users can simply make a copyof the file and bypass restrictions.
Passwords stored in script are visibleto editors.
Users can disable the script.
The file can be downloadedand edited offline.
It provides a false sense of security, which is worse than no security.
Below are stable, secure approaches that actually achieve the user’s goal.
How it works:
Create a Google Group (e.g., sheet-...@domain.com
).
Share the Sheet with the group as editor .
Share the Sheet publicly only as viewer (if needed).
Add/remove editors by managing the Group, not per person.
Pros:
Strong, native security.
No code.
Scalable for organizations.
Cons:
Requires accounts (preferably same domain).
Not suitable for public anonymous editors.
Architecture:
The Sheet is not sharedwith editors.
A Web App manages:
login/password entry,
form-like editing,
validation logic,
writing data to the Sheet via script.
How it works:
Users access a Web App link, not the Sheet.
Only the script (Web App) writes to the Sheet.
const SHEET_ID = 'YOUR_SHEET_ID' ; const PASSWORD = 'StrongPassword123' ; function doGet () { return HtmlService . createTemplateFromFile ( 'index' ) .evaluate() . setTitle ( 'Access Control' ); } function validatePassword ( pass ) { return pass === PASSWORD ; } function writeData ( data, pass ) { if (! validatePassword (pass)) throw new Error ( 'Invalid password' ); const ss = SpreadsheetApp . openById ( SHEET_ID ); const sh = ss. getSheetByName ( 'Data' ); sh. appendRow ([ new Date (), data. field1 , data. field2 ]); }
Pros:
The Sheet is fully protected.
Password logic stays within the Web App.
Any public user can access the interface.
Cons:
Users do not edit the sheet directly – they use a UI.
Password must be secured (hashing recommended).
Workflow:
Users submit data through a Google Form.
Apps Script validates an “access code”.
Valid responses are written to the Sheet.
The Sheet is not directly edited by users.
Pros:
Very easy to implement.
The Sheet stays protected.
Code-based filtering possible.
Cons:
Does not allow free-form sheet editing (only submissions).
If the users are within the same organization:
Set the Sheet to “Anyone in the domain with the link can edit”.
Enforce 2FA, SSO, or identity controls at the domain level.
Pros:
Strongest authentication.
No need for a password layer.
Cons:
Not usable for anonymous or external users.
You can complement any solution with:
onEdit
logs recording:
user who edited
before/after values
timestamps
Email or Chat alerts for sensitive changes.
Admin SDK Reports integration (activity tracking).
Relevant to the Admin SDK Reports Service
in the provided files.
These do not prevent editing but provide governance.
| Method | Security | Setup Effort | User Experience | Works with Public Link? |
|---|---|---|---|---|
|
Script-based password inside the sheet
|
Very Low | Low | Similar to desired | Yes, but insecure |
|
Workspace Groups + sharing permissions
|
High | Medium | Native Google UX | Partially (view only) |
|
Apps Script Web App front-end
|
High | Medium/High | Controlled UI | Yes |
|
Google Forms + validation
|
High | Low/Medium | Easy | Yes |
|
Domain-based access
|
High | Low | Transparent | Yes, inside domain |
|
Audit logs/alerts
|
Medium | Medium | Invisible | Works with all |
Google Sheets does notsupport password protection beyond Drive permissions.
Apps Script cannotenforce secure access restrictions if the Sheet is shared publicly for editing.
Any “password inside the sheet” is easily bypassed and offers no real security.
To achieve the user’s goal:
Keep the Sheet fully private.
Users interact with a secure UI.
Editing occurs only after password or code validation.
Editors managed via group membership.
Public can still view the file if needed.
Hello, I have a problem that I'm concerned about: how to set a password for Google Sheet. Besides setting permissions with the "Share" button, is there any solution for sheets with passwords? Thanks.
--
To view this discussion visit https://groups.google.com/d/msgid/google-apps-script-community/CAJ-AUmgfEDQkv2XAYmO7oFXLB4yLKYLgNFT_7ae4ACTVSNhWJg%40mail.gmail.com .
To view this discussion visit https://groups.google.com/d/msgid/google-apps-script-community/705ed4e2-e53d-44da-a1db-85268cb06d09n%40googlegroups.com .
To view this discussion visit https://groups.google.com/d/msgid/google-apps-script-community/f216c935-eced-4be8-9254-05d2f63eb402n%40googlegroups.com .
To view this discussion visit https://groups.google.com/d/msgid/google-apps-script-community/CAFKgK%2BHck6EUspY7WWwPErxqsew0SALS3x8o9nPopWARxWKRgw%40mail.gmail.com .