gpt4 book ai didi

google-apps-script - 复制工作表时,谷歌应用程序验证从谷歌应用程序脚本项目中丢失

转载 作者:行者123 更新时间:2023-12-02 03:01:37 24 4
gpt4 key购买 nike

我开发了一个使用电子表格作为其数据库的 google app scripts 应用程序,

我通过给客户一个 URL 来将应用程序提供给客户,以便他们从电子表格中制​​作副本(脚本在该电子表格上),他们授权并使用该副本。

最近,我的客户在授权脚本之前会看到“未经验证的应用程序”屏幕。所以我填写了一张谷歌验证表格,谷歌验证了它,但我的客户仍然看到未经验证的屏幕...

我怀疑问题是每个工作表在复制时都会得到一个新的项目 ID 和客户 ID,因此谷歌验证不适用于它们。

有谁知道我也可以验证副本的解决方案?还是有另一种方法可以将应用程序提供给人们而不需要他们制作副本并且每个人仍然应该有自己的脚本和电子表格?

最佳答案

虽然没有解决方案可以在制作副本时保留相同的项目 ID,但您可以将您的项目发布为 Web 应用程序并让该 Web 应用程序为您创建工作表并使用该工作表读取和写入数据。

这是我所做的

   function getCustomSpreadsheet(){
//try to get the spreadsheet id of the already created spreadsheet
var ssid = PropertiesService.getUserProperties().getProperty('customSsid');
//if sheet does not exist, create it
if(!ssid) var ssid = createCustomSpreadsheet();
var ss = SpreadsheetApp.openById(ssid);
return ss;
}

function createCustomSpreadsheet(){
//make a copy of your template spreadsheet and save its id to a property
fileId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";//your ss id here
var ss = DriveApp.getFileById(fileId).makeCopy();
var ssid = ss.getId();
PropertiesService.getUserProperties().setProperty('customSsid', ssid);
return ssid;
}


我在我的代码中到处找到/替换了 SpreadsheetApp.getActiveSpreadsheet()getCustomSpreadsheet() 并且从此过上了幸福的生活......

关于google-apps-script - 复制工作表时,谷歌应用程序验证从谷歌应用程序脚本项目中丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45576357/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com