gpt4 book ai didi

google-apps-script - 带有工作表插件的 Google Apps 脚本 PERMISSION_DENIED

转载 作者:行者123 更新时间:2023-12-03 16:11:43 27 4
gpt4 key购买 nike

我试图基于 THIS SHEET 实现一个简单的“多选择器侧边栏”扩展我在这个 Google support thread 中找到的

当我复制工作表时,它工作正常,但是当我尝试将完全相同的代码放入我的真实工作表中时,它不再起作用。
当我尝试从模板中访问 GA 函数时,它会引发错误。

我创建了一个简化的测试项目,它也无法为我工作。

重现错误:

  • https://docs.google.com/spreadsheets/ 创建一个新的电子表格
  • 创建第二个工作表(标签左下角)并将其命名为 CATEGORIES
  • 在第一列中填写几个字段。内容无所谓
    categories
  • 转到工具 -> 脚本编辑器

  • 在“code.gs”中输入
    function doGet() {
    var html = HtmlService.createHtmlOutputFromFile('Index')
    .setTitle('Multiple selector')
    .setWidth(300);
    SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
    .showSidebar(html);
    }

    function onOpen(e) {
    SpreadsheetApp.getUi().createMenu('Index')
    .addItem('Show Sidebar', 'doGet')
    .addToUi();
    doGet();
    }

    function getOptions() {
    var validation = {
    sheet: 'CATEGORIES',
    range: 'A2:A'
    }

    Logger.log("running getOptions");
    Logger.log(SpreadsheetApp.getActive().getSheetByName(validation.sheet).getRange(validation.range).getDisplayValues());
    return SpreadsheetApp.getActive().getSheetByName(validation.sheet).getRange(validation.range).getDisplayValues()
    .filter(String)
    .reduce(function(a, b) {
    return a.concat(b)
    })
    }

    并创建一个名为 Index.html 的第二个文件(HTML 文件)
    <!DOCTYPE html>
    <html>
    <head>
    <base target="_top">
    <script>
    function onFailure(error) {
    var div = document.getElementById('output');
    div.innerHTML = "ERROR: " + error.message;
    }

    google.script.run.withFailureHandler(onFailure)
    .getOptions();
    </script>
    </head>
    <body>
    <div id="output"></div>
    </body>
    </html>

    Testproject with the code
  • 保存项目
  • 单击运行-> 运行函数->“onOpen”(首次运行时您可能需要授权应用程序)

  • 现在在工作表中应该有一个侧边栏,它为我打开一个错误 PERMISSION_DENIED
    enter image description here

    即使我在资源 -> 云平台项目中选择了一个项目,它也不起作用。

    奇怪的是,如果我使用原始链接(工作)电子表格并更改代码中的某些内容,它将不再适用于我。

    我现在知道的事情:
    - 它不适用于我的 gmail 或 google 应用程序帐户
    - 对于使用相同文档的其他人,它有效
    - 如果我禁用 Adblocker 仍然不起作用
    - 如果我从隐身模式访问工作表不起作用
    - 如果我使用 Firefox 而不是 Chrome,它确实有效

    Console log from the browser

    我错过了什么?

    最佳答案

    我对“权限被拒绝”错误消息有同样的问题,我发现了这个

    https://github.com/burnnat/page-sizer/issues/3

    I think the issue is that I'm logged into multiple google accounts when I am working on this. I logged out of all google accounts, then only logged into the one account that I was trying to use formMule and it worked.



    所以我在 chrome 中使用隐身模式尝试了完全相同的代码,只登录了一个帐户,并且有效!

    我希望这可以帮助您解决您的问题。

    关于google-apps-script - 带有工作表插件的 Google Apps 脚本 PERMISSION_DENIED,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60412319/

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