1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Exception: The script does not have permission to perform that action. Required permissions

Last updated at Posted at 2020-05-30

:scream: エラー

画像

image.png

Detailsをクリックしたら表示された

image.png

メッセージ

Message details
Exception: The script does not have permission to perform that action. Required permissions: (https://www.googleapis.com/auth/gmail.send || https://www.googleapis.com/auth/gmail.compose || https://www.googleapis.com/auth/gmail.modify || https://mail.google.com/ || https://www.googleapis.com/auth/gmail.addons.current.action.compose) (line 12, file "sendGmail")

:o: 解決法

appsscript.jsonを修正する

1. 既に、appsscript.jsonに"oauthScopes"が存在していれば何もしない。なければ、作成する。

appsscript.json

{
  ...
  "oauthScopes": []
}

2. エラーメッセージの()内部を切り出す

今回はこれ

errorMessage
https://www.googleapis.com/auth/gmail.send || https://www.googleapis.com/auth/gmail.compose || https://www.googleapis.com/auth/gmail.modify || https://mail.google.com/ || https://www.googleapis.com/auth/gmail.addons.current.action.compose

3. 2を読み取る

全て、|| でつながっているので、どれかを使用すれば良いことがわかる。
今回は試しに https://www.googleapis.com/auth/gmail.sendを使う

errorMessage
https://www.googleapis.com/auth/gmail.send || https://www.googleapis.com/auth/gmail.compose || https://www.googleapis.com/auth/gmail.modify || https://mail.google.com/ || https://www.googleapis.com/auth/gmail.addons.current.action.compose

4. 1で作成した"oauthScopes"の[]に追記する。

appsscrips.json

{
  ...
  "oauthScopes": [
    "https://www.googleapis.com/auth/gmail.send"
  ]
}

メールが送信できた :cake:

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?