Google apps script 从GMail插件访问Google文档
我在通过GMail插件访问Google文档时遇到问题 我想从我的GMail插件中复制特定的Google文档文件,然后编辑新文档。我可以使用以下方法从我的模板文档创建新文档:Google apps script 从GMail插件访问Google文档,google-apps-script,google-docs,gmail-addons,Google Apps Script,Google Docs,Gmail Addons,我在通过GMail插件访问Google文档时遇到问题 我想从我的GMail插件中复制特定的Google文档文件,然后编辑新文档。我可以使用以下方法从我的模板文档创建新文档: var docTemplate="<DOCUMENT ID>"; var docName = "Generated Document 123"; var copyId = DriveApp.getFileById(docTemplate).makeCopy(docName).getId(); 我在G
var docTemplate="<DOCUMENT ID>";
var docName = "Generated Document 123";
var copyId = DriveApp.getFileById(docTemplate).makeCopy(docName).getId();
我在GMail加载项窗格中看到一个错误:“您没有调用openById的权限[行:36,函数:getContextualAddOn,文件:Code]”
我在Google Sheets的应用程序脚本中成功地使用了相同的代码,所以我假设我没有正确设置权限
在清单文件中,我将oauthScopes值设置为:
"oauthScopes": [
"https://www.googleapis.com/auth/gmail.addons.execute",
"https://www.googleapis.com/auth/gmail.readonly",
"https://www.googleapis.com/auth/drive",
"https://www.googleapis.com/auth/script.external_request"
]
/auth/drive权限允许我调用DriveApp.getFileById(),但是调用DocumentApp.openById()需要什么不同的权限呢?还是有其他问题
如有任何提示/指导,将不胜感激 添加以下内容:
如果此答案对您有帮助,请向上投票…这在以下章节中提到:
与大多数其他类型的应用程序脚本不同,自定义函数从不要求
用户授权访问个人数据。因此,他们可以
仅限于无法访问个人数据的呼叫服务,
具体如下:
>无法打开其他电子表格(SpreadsheetApp.openById()或
SpreadsheetApp.openByUrl())
将“”添加到我的oauthScopes解决了这个问题。谢谢(我的投票记录了下来,但没有显示。)是的,这让你通过了它的权限部分。我在那之后遇到了另一个错误,这可能说明了下面评论的要点。您好!我可以很好地访问我的文档(谷歌文档)。例如,
var doc=DocumentApp.create(myFileName)代码>
"oauthScopes": [
"https://www.googleapis.com/auth/gmail.addons.execute",
"https://www.googleapis.com/auth/gmail.readonly",
"https://www.googleapis.com/auth/drive",
"https://www.googleapis.com/auth/script.external_request"
]