Google apps script requires permissions that are already granted

时光毁灭记忆、已成空白 提交于 2019-12-11 06:28:39

问题


Here's the function in question:

function GetResponseDate(confirmation) {

  var threads = GmailApp.search(confirmation);
  var initialResponse;
  if(threads.length!=0){
   initialResponse = threads[0].getMessages()[0].getDate(); 
  }
  else{
    initialResponse = "none";
  }

  return initialResponse;

}

Here's the manifest:

{  
  "oauthScopes":[
    "https://www.googleapis.com/auth/gmail.readonly",
    "https://www.googleapis.com/auth/gmail.addons.current.message.readonly",
    "https://www.googleapis.com/auth/gmail.addons.current.message.action",
    "https://www.googleapis.com/auth/gmail.modify" 
    ],
  "timeZone": "America/Los_Angeles",
  "dependencies": {
  },
  "exceptionLogging": "STACKDRIVER"
}

The implementation is just

= GetResponseDate("12345")

within a cell.

I've granted all of the permissions requests that have popped up (whether by default, or the additional ones I added in the manifest file), but I still get the sheets error:

The script does not have permission to perform that action. Required permissions: (https://www.googleapis.com/auth/gmail.readonly || https://www.googleapis.com/auth/gmail.addons.current.message.readonly || https://www.googleapis.com/auth/gmail.addons.current.message.action || https://www.googleapis.com/auth/gmail.modify || https://mail.google.com/) (line 3).

回答1:


Answered by Alan Wells and Tanaike (though I can't upvote them because my account is new).

Solution is: individual cell formulas can't request permissions, and the correct permission to request is https://mail.google.com/. One workaround is: execute script as a menu item instead of within a cell (though it needs to be modified to interpret and output to cells).



来源:https://stackoverflow.com/questions/56799257/google-apps-script-requires-permissions-that-are-already-granted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!