【发布时间】:2015-05-28 08:20:05
【问题描述】:
我在这里查看了答案:How do I stop the error, Authorisation is required to perform that action in Google Script。这并不能解决我的问题,因为我没有更改任何代码,并且在第一次运行代码时我已经授权了该代码。突然间我收到Authorization is required to perform that action 错误。
我也试过这个链接https://developers.google.com/apps-script/troubleshooting#common_errors 并在编辑器function test() { var a=1} 中运行了一个空白函数。这运行正常,没有提示我授权脚本并且没有错误。因此,按照 Google 的说明操作后:To authorize the script, open the Script Editor and run any function. 我仍然收到Authorization is required to perform that action 错误。
我没有做任何花哨的事情。该脚本只有一个.gs文件,该文件只有一个功能。我没有使用任何高级服务,也没有将其链接到任何库。
更新:我尝试制作文件的副本,然后再次进入脚本编辑器运行代码。这次授权弹出在那里,所以我点击继续。如下所示:代码想要
View and manage the files in your Google Drive.
Send email as you
Connect to an external service
我点击“接受”。代码开始运行,2 秒后Authorization is required to perform that action. 现在每次我尝试运行代码时,它甚至都没有给我弹出授权。它只是给了我错误。
这里是代码的 oauth 部分。其余的代码只是多几行。
var oauthConfig = UrlFetchApp.addOAuthService("google");
var scope = "https://docs.google.com/feeds/";
//make OAuth connection
oauthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
oauthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope="+scope);
oauthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
oauthConfig.setConsumerKey("anonymous");
oauthConfig.setConsumerSecret("anonymous");
//get request
var request = {
"method": "GET",
"oAuthServiceName": "google",
"oAuthUseToken": "always",
"muteHttpExceptions": true
};
【问题讨论】:
-
您在使用任何高级谷歌服务吗?
-
我查看了脚本编辑器中的资源部分。一切都关闭了。我没有使用任何高级服务。
-
之前的代码是否有效?如果没有,您可以发布它以便我们检查错误是否在您的代码中?
-
是的,在发生这种情况之前,它工作了大约一个月。我现在已经包含了代码的 oauth 部分。
-
成绩单/日志中有什么?
标签: google-apps-script authorization