首页 文章

Google Vision API会返回PERMISSION_DENIED

提问于
浏览
2

我'm trying to use the Google Vision API. I' m跟随getting started guide

  • 我启用了Cloud Vision API

  • 我启用了结算功能

  • 我已经设置了一个API密钥

  • 从我的图像中制作了base64编码的数据

  • 使用设置制作JSON文件:

{
  "requests":[
    {
      "image":{
        "content":"my base64-encoded data"
      },
      "features":[
        {
          "type":"LABEL_DETECTION",
          "maxResults":5
        }
      ]
    }
  ]
}
  • 已使用 curl 发送请求:
$ curl -v -k -s -H "Content-Type: application/json" https://vision.googleapis.com/v1/images:annotate?key=my_browser_key --data-binary @path_to_file.json

之后我收到了回复:

{
      "error": {
        "code": 403,
        "message": "Requests from referer \u003cempty\u003e are blocked.",
        "status": "PERMISSION_DENIED",
        "details": [
          {
            "@type": "type.googleapis.com/google.rpc.Help",
            "links": [
              {
                "description": "Google developer console API key",
                "url": "https://console.developers.google.com/project/***********/apiui/credential"
              }
            ]
          }
        ]
      }
    }

\ u003cempty \ u003e表示<empty>

有任何想法吗?有人有同样的问题吗?

1 回答

  • 4

    您是否在该页面上显示的“接受来自这些HTTP引用者的请求”框中指定了有效引用者列表?如果你这样做,你可能必须指定其中一个:

    curl --referer https://yourwebsite.com/ ...
    

    或者,如果您不需要,请禁用引用检查 .

相关问题