[英]How do I allow users to edit my Sheets file via my own Google Scripts Web App?
I'm quite new Google Scripts.我是新的谷歌脚本。 I'm trying to create a web app through which users can log in (with their Gmail accounts) and modify a Google Sheet.我正在尝试创建一个 web 应用程序,用户可以通过该应用程序登录(使用他们的 Gmail 帐户)并修改 Google 表格。 Here's a screenshot of the registration page.这是注册页面的截图。
Initially, the user logs in via their existing Google account and this page is displayed.最初,用户通过他们现有的 Google 帐户登录并显示此页面。 Upon clicking the button, what I want is for the script to add their submitted information and their current email to a Google Sheet.单击按钮后,我想要脚本将他们提交的信息和他们当前的 email 添加到 Google 表格中。 Once their info is in the Sheet, they only need to log in via Google to gain access to the system.一旦他们的信息出现在工作表中,他们只需通过 Google 登录即可访问系统。 However, when I try this with another account I get this error:但是,当我使用另一个帐户尝试此操作时,我收到此错误:
Is this a permissions problem?这是权限问题吗? Or does Google Scripts not allow this kind of direct manipulation of files on my Drive?还是 Google Scripts 不允许对我的云端硬盘上的文件进行这种直接操作? Here are my permissions settings for my web app:这是我的 web 应用程序的权限设置:
Is this at all possible?这是可能吗?
From your question, I could understand that the settings of your Web Apps is as follows.根据您的问题,我可以理解您的 Web 应用程序的设置如下。
Execute the app as: User accessing the web app
Who has access to the app: Anyone
For above Web Apps, you want to make users access to the Web Apps using each browser.对于上述 Web 应用程序,您想让用户使用每个浏览器访问 Web 应用程序。
From above situation, please confirm the following points.从以上情况,请确认以下几点。 At first, I think that when the Spreadsheet you want to put the values is in each user's Google Drive, no error occurs.起初,我认为当您要放置值的电子表格在每个用户的 Google Drive 中时,不会发生错误。 So from your question, I thought that the Spreadsheet might be in your Google Drive.所以从你的问题来看,我认为电子表格可能在你的谷歌驱动器中。
getActiveSpreadsheet()
is used, it is required to share the Spreadsheet with the user.即使Web Apps的脚本是Spreadsheet的容器绑定脚本,使用getActiveSpreadsheet()
,也需要与用户共享Spreadsheet。
If you don't want to share the Spreadsheet with the user, how about the following workaround?如果您不想与用户共享电子表格,以下解决方法如何?
Execute the app as: Me
Who has access to the app: Anyone, even anonymous
Who has access to the app: Anyone
is used, it is required to share the script of new Web Apps with the user.当Who has access to the app: Anyone
,需要与用户共享新的Web 应用程序的脚本。 So I proposed to use Anyone, even anonymous
for this situation.所以我建议在这种情况下使用Anyone, even anonymous
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.