google-cloud-platform - 项目中没有使用过API或者被禁用403错误

标签 google-cloud-platform oauth-2.0

我正在使用应用脚本连接到 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"
    ]
}

最佳答案

Default Cloud Platform project 切换脚本给您Standard Cloud Platform project

  • Here是如何更改为标准项目的说明 - 取决于您使用新编辑器还是旧编辑器。

  • 成功切换到标准项目后 - enable Content API for Shopping 以及您想要在 GCP 控制台中使用的任何其他 API。

  • 如果您使用模拟服务帐户,您还需要在管理控制台中为服务帐户分配必要的范围,如 here 中所述。 .

关于google-cloud-platform - 项目中没有使用过API或者被禁用403错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69030008/

相关文章:

java - Spring Boot 中的 Google 云部署错误 - 部署失败 : Non zero exit: 1

google-cloud-platform - 使用 terraform 配置 bigquery 数据集

java - 在java中设置谷歌云存储桶访问日志

python - 如何自动对 basecamp 3 api 进行身份验证(最好在 python 中)?

当我尝试通过 GCP 部署命令托管 Node.js 应用程序时,它不起作用。错误 : Cannot find module 'express'

tensorflow - 如何在 tensorflow 中读取 utf-8 编码的二进制字符串?

c# - DotNetOpenAuth 4 不读取配置值

java - Oauth2 Java 配置 JDBC

facebook-graph-api - 根据 OAuth 2.0 RFC 处理 Facebook API 权限跳过/撤销

android - RxJava : How to refresh a token when multiple requests are sent at the same time?