LANG SELRCT

Apps Script Reference  (Create: Create new Spreadsheet | Create new Apps Script

Sunday, March 31, 2019

Google APIのスコープ一覧を知りたい


Google Apps Scriptのスコープを設定したくて調べた備忘録


一覧はここに書かれていた

OAuth 2.0 Scopes for Google APIs
https://developers.google.com/identity/protocols/googlescopes



Google Apps Scriptのスコープを設定してみる


「スコープ」は書かれたコードから自動判定されるようですが、広すぎるようです


「スコープ」って何?

  • スクリプトの実行に必要なアクセス権
  • スクリプトを実行するユーザのデータに対して、どんな操作を行うか
  • 例えば「データを読むだけ」とか「アプリで作ったデータの読み書きだけ」とか



どこに書かれているか
「ファイル > スクリプトのプロパティ > スコープ」 の中で確認できる


どこで設定できるか
「表示 > マニフェスト ファイルを表示」でappsscript.jsonが開くので

  "oauthScopes": [
    "https://www.googleapis.com/auth/drive.file"
  ],

このように追加してやる




manifest.json
{
  "timeZone": "Asia/Tokyo",
  "dependencies": {
  },
  "oauthScopes": [
    "https://www.googleapis.com/auth/drive.file"
  ],
  "exceptionLogging": "STACKDRIVER"
}


参考

Authorization Scopes (manifest.jsonに書くScope)
https://developers.google.com/apps-script/concepts/scopes


OAuth 2.0 Scopes for Google APIs (Scopeの一覧)
https://developers.google.com/identity/protocols/googlescopes


Authorize Requests (スプレッドシートのスコープ)
https://developers.google.com/sheets/api/guides/authorizing

Latest post

スプレッドシートA列にある複数のテキストをスライドに追加したい(Google Apps Script)

今回Google Apps Scriptでやりたいこと GoogleスプレッドシートA列にある複数の値を取得して Googleスライドに渡して 図形オブジェクトのテキストとして追加したい ① スプレッドシートのA列に値を入れておく ② Code.gsのinsertNewShape...