![](/img/trans.png)
[英]Using Google Picker as a Library returning "ScriptError: Authorization is required to perform that action." for other users
[英]"ScriptError: Authorisation is required to perform that action." when running google.script.run from Library
問候,
我發現了有關此錯誤的幾個問題: "ScriptError: Authorisation is required to perform that action."
但我找不到一個關於我的問題。
我想要做的是使用 google.script.run 從 .html 文件調用函數 .gs 文件,其中兩個文件都在庫中。 參考這個答案,這個答案和這個錯誤報告,我在使用庫的腳本中創建了“包裝函數”,但仍然無法完成執行。
這是我所做的:
.html 在庫中:
<html> <head> <script> function onFailure(error) { console.log("ERROR: " + error); } function myfunc() { console.log("HERE"); google.script.run.withFailureHandler(onFailure).callLibraryFunction('LibraryName.test', ['test123']); } </script> </head> <body> <button onclick="myfunc()">CLICK</button> </body> </html>
.gs 在圖書館
function test(x){ Logger.log(x); }
.gs 在使用庫的腳本中:
function callLibraryFunction(func, args) { var arr = func.split("."); var libName = arr[0]; var libFunc = arr[1]; args = args || []; return this[libName][libFunc].apply(this, args); }
控制台在HERE
記錄,然后記錄ERROR: ScriptError: Authorisation is required to perform that action.
而不是預期的輸出, test123
。
注意:HTML 適用於表格中的自定義無模式對話框,而不適用於 Web 應用程序。
我真的希望有人能幫助我。 先感謝您。
您需要像授予對調用腳本的訪問權限一樣,在 Gmail 帳戶中將庫“LibraryName”作為授權應用程序授予訪問權限。 我猜你已經在你的庫中調用了HtmlService.createHtmlOutputFromFile(...)
方法。 這需要更多的授權。 你需要授予這一點。 您可以做的是在具有HtmlService.createHtmlOutputFromFile(..)
的庫中創建一個臨時函數。 從腳本編輯器運行它,然后出現授權要求窗口。 繼續授予訪問權限...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.