13

I'm working on a Google Sheets script that I'm only intending to access data in the same spreadsheet that the .gs file is associated with. It seems like I should have permission to run a script in my own spreadsheet, but whenever I run a function, I get a This app isn't verified message.

How do I bypass this? I've already enabled the Google Sheets API in both Advanced Google Services and the API Console. Am I wrong in assuming that if I create a spreadsheet and create an add-on that modifies that spreadsheet, that I shouldn't have to authorize it?

Here's the function that's throwing the error:

function getLastRow(){
  ss=SpreadsheetApp.getActiveSpreadsheet();
  var rulesSht=ss.getSheetByName('rules');
  return rulesSht.getLastRow();
}
sigil
  • 9,370
  • 40
  • 119
  • 199
  • Does this answer your question? [This app isn't verified This app hasn't been verified by Google yet. Only proceed if you know and trust the developer](https://stackoverflow.com/questions/45437557/this-app-isnt-verified-this-app-hasnt-been-verified-by-google-yet-only-procee) – ggorlen Feb 19 '20 at 19:56
  • 1
    The automatic scopes allocated by use of the SpreadsheetApp apply to all spreadsheets in the users Google Drive. So be explicit: include the `//@OnlyCurrentDoc` annotation comment (which will prevent the access of anything outside of this document), or declare your OAuth scopes as read-only. You can find more details in the official documentation. – tehhowch May 03 '20 at 17:25

2 Answers2

17

When "This app isn't verified" is displayed, the screen will be not displayed by authorizing once to use scopes which are used in the script. When users use APIs of Google, they are required to authorize for the scopes which are used in scripts. The flow of authorization is as follows.

  1. When "This app isn't verified" is displayed, click "Advanced".
  2. Click "Go to filename(unsafe)".
  3. Confirm scopes and click "ALLOW".

By this, the screen will be not displayed when you run the script again. When you modified your script, if new scopes are detected, the screen is displayed to authorize new scopes again. Such scopes are automatically detected at script editor. That authorization is required to do only once.

Note :

  • In your snippet of question, you can use the script without enabling Sheets API at Advanced Google Services and the API Console.

If I misunderstand your question, I'm sorry.

Tanaike
  • 181,128
  • 11
  • 97
  • 165
  • 1
    Looks like Google has taken away the Advanced option. Kinda crazy you can't run scripts on your documents. Google might as well say they just killed the scripts feature. – Donny V. Jun 22 '20 at 14:46
  • @Donny V. Thank you for your additional information. – Tanaike Jun 23 '20 at 00:10
  • Update on Donny's comment, the Advanced option is still available for me. – Elliott Collins Jan 10 '22 at 16:17
  • @Elliott Collins About `Update on Donny's comment, the Advanced option is still available for me.`, I have to apologize for my poor English skill. Unfortunately, I cannot understand your comment. Can I ask you about the detail of it? – Tanaike Jan 11 '22 at 00:22
0

I had the same problem with a script I intended for distribution to other people. After some experimentation I found that it was that one of my function titles contained the word "show" and removing that took away the error.

I am unable to find any documentation on why that would be, but removing it solved the problem. Perhaps trying different names and submitting a ticket to Google with the word that caused it may be the best that can be done at this point.