我正在使用应用脚本连接到 Google 的 Content API。要通过 oAuth2
进行身份验证,我在 appsscript.json 文件中设置范围。然后,我调用 ScriptApp.getOAuthToken() 来获取必要的访问 token 。
但是,我收到 403 响应和如下错误:
Content API for Shopping has not been used in project XXXX before or it is disabled.
Enable it by visiting https://console.developers.google.com/apis/api/shoppingcontent.googleapis.com/overview?project=XXXX then retry.
If you enabled this API recently, wait a few minutes for the action to propagate to our
systems and retry
问题是错误中的项目 ID 与我的服务帐户所在的项目 ID 不匹配。事实上,该项目似乎根本不存在。
我已为工作表的脚本 ID 启用客户端 ID 并将其添加到重定向 URI
部分,但它似乎转到了错误的位置。我很难理解为什么我会被重定向到这个不存在的项目。
appsscript.json 如下:
{
"timeZone": "Europe/London",
"dependencies": {
"libraries": [
{
"userSymbol": "OAuth2",
"version": "41",
"libraryId": "XXXX"
}
]
},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"oauthScopes": [
"https://www.googleapis.com/auth/content",
"https://www.googleapis.com/auth/script.external_request"
]
}
最佳答案
关于google-cloud-platform - 项目中没有使用过API或者被禁用403错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69030008/