Google App Scripts cannot be given Authorization or Permission

天涯浪子 提交于 2019-12-17 09:58:30

问题


Why am I not able to give permission/authorization to a Google Apps Script that I also made using the same Google account?

It seems like Google doesnt trust myself to use my own Google Apps Script with my own Spreadsheet.

Here is the line of code that breaks everything. If this line doesnt exist, I'm not asked for permission.

var sheet = SpreadsheetApp.getActiveSheet();

So it's trying to access the spreadsheet that created this Google Apps Script, also made using my account but I cant grant permission.

When I run the line of code above, I am told I need to give permissions, so I do by selecting the account name I am already logged into. I am greeted by this error,

This app isn't verified

which unfortunately does not provide competent documentation to troubleshoot.

Any feedback or help would be much appreciated! Thanks!


回答1:


Click on the "Advanced" link and you'll be able to authorize your script.




回答2:


To reduce the scope of permissions you request, you also have the option of declaring your script project to be only able to interact with the bound document:

/* @OnlyCurrentDoc */
function myFunction() {
  ...

This declaration is incompatible with some methods (such as SpreadsheetApp.openById()), and using an incompatible method results in an error in the application execution.

Successfully adding it to your project is generally sufficient to remove the "This application is unsafe" layer of the authentication flow, meaning the authorization and permission list is not hidden behind the "Advanced" tab.

In addition to declaring as current document only, manually editing the requested scopes of your project in its project manifest can help reduce the perceived threat from an unverified application (for example, retaining only the "read_only" version of certain scopes, where applicable). Apps Script documentation offers more details on project manifests.



来源:https://stackoverflow.com/questions/49317412/google-app-scripts-cannot-be-given-authorization-or-permission

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