简体   繁体   English

运行 Google Docs Add On Drive 权限

[英]Running Google Docs Add On Drive permissions

I have tried to create my first google docs add-on.我试图创建我的第一个谷歌文档插件。

When I had run the script within a google doc, it worked just fine.当我在谷歌文档中运行脚本时,它工作得很好。 However, when I am publishing the add-on and then installed it, it does not work.但是,当我发布插件然后安装它时,它不起作用。 The error message is:错误信息是:

Exception: We're sorry, a server error occurred.例外:很抱歉,发生服务器错误。 Please wait a bit and try again请稍等,然后重试

I have determined that the line of code which causes the issue is the last one here:我已经确定导致问题的代码行是这里的最后一行:

  var currentDocumentName = DocumentApp.getActiveDocument().getName();
  var currentDocumentID = DocumentApp.getActiveDocument().getId();
  var currentfile = DriveApp.getFileById(currentDocumentID);

So it would appear that using the DriveApp cannot run for some reason.因此,使用 DriveApp 似乎由于某种原因无法运行。

I know this is the line with error for two reasons.我知道这是错误的原因有两个。 The error message in the google console log says it is this line number.谷歌控制台日志中的错误消息说它是这个行号。 Also, when I put in some logging messages, the messages end where this line is executed.此外,当我输入一些日志消息时,消息会在执行此行的位置结束。 I have given the Google drive API permission in the project.我已经在项目中授予了谷歌驱动器 API 权限。

Does anyone know why this error could occur?有谁知道为什么会发生这个错误?

How can I get this to work?我怎样才能让它工作?

This seems to be a bug .这似乎是一个错误 You can click on the star next to the issue number to receive updates and to give more priority to the bug.您可以单击问题编号旁边的星号以接收更新并为该错误提供更多优先级。

As a workaround, try with the Drive API instead (which is different from DriveApp):作为一种解决方法,请尝试使用Drive API (与 DriveApp 不同):

var file = Drive.Files.get("fileId");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM