Google cloud vision Google Vision API返回权限\u被拒绝

Google cloud vision Google Vision API返回权限\u被拒绝,google-cloud-vision,Google Cloud Vision,我正在尝试使用Google Vision API。我以下是: 我已经启用了云视觉API 我已启用计费 我已经设置了一个API密钥 从我的图像生成base64编码数据 使用以下设置创建JSON文件: { "requests":[ { "image":{ "content":"my base64-encoded data" }, "features":[ { "type":"LABEL_DETECTI

我正在尝试使用Google Vision API。我以下是:

  • 我已经启用了云视觉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表示


    有什么想法吗?有人有同样的问题吗?

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

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

    如果您不需要,也可以禁用referer检查。

    你好,Matti,谢谢您的回复。不,我没有指定有效推荐人的列表。你认为这可能是原因吗?@akomkov医生似乎说,如果你把它留空,任何推荐人都可以,但我想它不是最新的。在“那”页上?哪一页?请指明指定此检查的位置。很好的呼叫,@VisionHive-他指的是云控制台中的此页面:
    https://console.cloud.google.com/apis/credentials?project=&authuser=&organizationId=
    (一旦我将referer指定为
    https://.appspot.com/*
    它又起作用了)