javascript - Google App 脚本 - 例外:您无权调用 UrlFetchApp.fetch
问题描述
在OnOpen()
函数上,我运行一个自定义函数来检查用户令牌是否有效,但我从谷歌得到以下错误。
Google Apps Script: Error: Error: Exception: You do not have permission to call UrlFetchApp.fetch. Required permissions:
我已经在网上查过了,解决办法是在appscript.json
https://www.googleapis.com/auth/script.external_request
我已经添加了,但我仍然从谷歌收到同样的错误。
这就是我的appscript.json
样子
{
"timeZone": "America/New_York",
"dependencies": {
},
"exceptionLogging": "STACKDRIVER",
"oauthScopes": ["https://www.googleapis.com/auth/script.external_request", "https://www.googleapis.com/auth/spreadsheets", "https://www.googleapis.com/auth/script.container.ui"],
"runtimeVersion": "V8"
}
这是我的onOpen()
功能
const onOpen = () => {
const { token } = getPresetData();
if (token) {
const isTokenValid = validateUserToken(); // <---- this is where I make a request to my server
if(isTokenValid){
console.log('token is valid');
getMenu(true);
}else{
console.log('token is not valid');
getMenu(false)
}
} else {
console.log('token is undefined');
getMenu(false);
}
};
解决方案
推荐阅读
- json - AWS Cloudwatch Log Insights - 通过 JSON 过滤器对 JSON 日志事件过滤记录
- react-native - 如何从 DrawerNavigator 内的屏幕导航到同一 DrawerNavigator 内的另一个屏幕
- python - 函数中的多个参数。通过函数传递信息。- ''
未找到' - sqlite - 将 Sqlite 和 Knex 与 Node 模块一起使用
- ffmpeg - 以相同质量转换
- python - 了解钻石继承中的super()
- sql - 在推文字符串中删除 @ImSRK 的大查询
- android - AAPT:错误:意外元素
在发现 - angular7 - ERROR TypeError: _co.Get_products is not a function
- macos - 管道后“找不到命令”