何気にGASについて書くのは初めてだった。
GASでIDを使ってシートを指定してアクセスしようとすると下記のように怒られることがある。
Exception: SpreadsheetApp.openById を呼び出す権限がありません。必要な権限: https://www.googleapis.com/auth
対策としては、マニュフェスト(appsscript.json)に下記を追加することで対処する。
"oauthScopes": ["https://www.googleapis.com/auth/spreadsheets.currentonly", "https://www.googleapis.com/auth/spreadsheets"],
実行 > マニュフェスト ファイルを表示と進んで行くと変更することができる。
appsscript.jsonに下記のように先ほどの1行を入れ込む。
{ "timeZone": "Asia/Tokyo", "dependencies": { }, "exceptionLogging": "STACKDRIVER", "oauthScopes": ["https://www.googleapis.com/auth/spreadsheets.currentonly", "https://www.googleapis.com/auth/spreadsheets"], "runtimeVersion": "V8" }
これでアクセスできるようになるっぽい。