GAS エラー「Exception: You do not have permission to call UrlFetchApp.fetch. Required permissions: https://www.googleapis.com/auth/script.external_request」が発生した場合の対処法
- 作成日 2023.12.19
- Google Apps Script
GAS(Google Apps Script)で、エラー「Exception: You do not have permission to call UrlFetchApp.fetch. Required permissions: https://www.googleapis.com/auth/script.external_request」が発生した場合の対処法を記述してます。
環境
- OS windows11 home
- ブラウザ chrome 120.0.6099.71
エラー全文
以下のchatに通知を送るプログラムで発生
const postGoogleChat = (message) => {
let webhookUrl = "https://chat.googleapis.com/v1/spaces/xxxxx";
message = {
'text': message
};
let options = {
'payload': JSON.stringify(message),
'myamethod': 'POST',
'contentType': 'application/json'
};
let response = UrlFetchApp.fetch(webhookUrl, options);
}
エラーメッセージ
エラー
Exception: You do not have permission to call UrlFetchApp.fetch. Required permissions: https://www.googleapis.com/auth/script.external_request
原因
appsscript.jsonを編集していたため、oauthScopesに「”https://www.googleapis.com/auth/script.external_request”」を追加する必要がありました。
対処法
「”https://www.googleapis.com/auth/script.external_request”」を追加する
"oauthScopes": [
"https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/contacts",
...,
...,
...
],
-
前の記事
Finder ファイルをプレビューするショートカットキー 2023.12.19
-
次の記事
MariaDB 乱数を取得する 2023.12.20
コメントを書く