不允许我将编辑保存到 appsscript.json



我想访问与用户google帐户关联的名称,以解决GoogleJsonResponseException: API call to people.people.get failed with error: The caller does not have permission to request "people/me". Request requires one of the following scopes: [profile]错误。

为此,我尝试将https://www.googleapis.com/auth/userinfo.profile谷歌的OAuth 2.0作用域列表中列出的作用域。但是,在编辑appsscript.json以手动包含范围(如本文所述(并尝试保存后,它不起作用。它显示";正在保存项目"弹出,但它从来没有解决和重新加载页面重置appscript.json没有我的更改。范围https://www.googleapis.com/auth/userinfo具有相同的响应。没有与此相关的错误消息。

这是我目前的档案——我遗漏了什么愚蠢的东西吗?我做错了吗?

{
"oauthScopes": "https://www.googleapis.com/auth/userinfo.names",
"timeZone": "America/New_York",
"dependencies": {
"enabledAdvancedServices": [
{
"userSymbol": "People",
"version": "v1",
"serviceId": "peopleapi"
}
]
},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"webapp": {
"executeAs": "USER_DEPLOYING",
"access": "MYSELF"
}
}

如果任何文件出现语法错误,Google Apps脚本IDE/在线编辑器将不允许保存项目。在appsscript项目清单(appsscript.json(的特定情况下,该文件应该具有有效的json,并且应该具有特定的结构。

在中指定了Apps Script项目清单结构https://developers.google.com/apps-script/manifest.


在OP提到的特定情况下,oauthScopes属性应包含一个数组或字符串。考虑到这一点,更改

"oauthScopes": "https://www.googleapis.com/auth/userinfo.names",

通过

"oauthScopes": [ "https://www.googleapis.com/auth/userinfo.names" ],

手动编辑清单时的另一个典型错误是忘记添加逗号来分隔两个属性。

最新更新