I'm very new to Google Apps Script, so I'm sorry if this is a super basic question. I've tried searching for similar questions, but the closest I could find didn't work. This person from two years ago seems to have a very similar problem, but there aren't any solutions listed.
I'm using my personal Google account, and trying to use simple code to automate formatting of a Google Sheets spreadsheet that I created. I'm not trying to share access with anyone else. The smallest reproducible example is opening a fresh spreadsheet, clicking "Apps Script" under Extensions in the toolbar, pasting this into the code editor, clicking "save" and then "run":
function Untitled() {
var mySS = SpreadsheetApp.getActiveSpreadsheet();
}
When I run it, it says I have to give it permissions, so I click on my Google account in the pop-up. This window comes up, like in the first post I linked, saying "Google hasn't verified this app":
I click "Advanced," and then "go to Untitled project (unsafe)," but then a small black window comes up in the bottom-left of the pop-up comes up that says "Something went wrong. Please try again."
I've tried clearing my browser cache/cookies/data, on the off-chance that that could help. I've also tried going through my Google Account settings, but didn't immediately see anything that would affect this. It occurs whether the spreadsheet is listed as private for only me, or if it's public, with anyone with the link able to edit.
I also tried adding /* @OnlyCurrentDoc */
directly above the function, which was mentioned in a lower answer in the first question linked above. This seems to bring me a page further, and gives me the 'this page is requesting these permissions' message, but when I click "allow," it gives me a similar error message.
Does anyone know why it's not allowing me to give it permission? Or alternatively, is there a different way to accomplish automated sheet formatting without needing to get the permissions? Thank you!
I have many AppsScripts written for my spreadsheets and have never encountered this. I tested your workflow by clicking 'Run' in the AppsScript editor, and sure enough I got the permissions pop-up (that I have never seen before). I have a workaround you can use. Try testing in your spreadsheet instead of in AppsScript. For example, add this to your code:
function onEdit(e) {
Browser.msgBox('testing');
}
This is a function that will trigger any time the spreadsheet is edited. https://developers.google.com/apps-script/guides/triggers/
Then return to the spreadsheet that the script is tied to and type something in one of the cells, triggering an edit. You should get the popup saying 'testing' which will let you know that the AppsScript is connected and working. From here you can continue debugging via message boxes and editing your script as needed.
Maybe the error is because you aren't running it through a spreadsheet when you're in the editor. That part I don't know.